Corrected waitFor condition