Now uses indefinite wait instead of while loop