Two concerns here.
1. The invoking is not accurate. Received title is not equal to title changed. You may either change the callback name or add the logic to justify whether the title is changed from last time.
2. If the title changing happens before the code gets to call the wait function, then the wait will last forever or til the timeout. It can happen due to some threading scheduling.