waitToAppear(60) for 2 Element and not 1

Hi, I need help wih APPIUM for Android.

I’m using the waitToAppear(20) to wait until element will applay on the screen, like this ::

// waitToAppea function //

public UiObject waitToAppear(int seconds) {
    MyLogger.log.debug("Waiting to Appear for element: "+locator);
    Timer timer = new Timer();
    timer.start();
    while(!timer.expired(seconds)) if(exist()) break;
    if(timer.expired(seconds) && !exist()) throw new AssertionError("Element "+locator+" failed to appear within "+seconds+" seconds");
    return this;
}

// Element //

title1 = new UiSelector().resourceId(PackageID1).text(“OLD Message”).makeUiObject();
title2 = new UiSelector().resourceId(PackageID2).text(“New Message”).makeUiObject();

// Wait to the Element

title1.waitToAppear(20);

the problem that sometimes element title1 will apply and sometimes Element title2 will apply.

Who do i wait Until title1 or title1 will apply ?

Thanks!