wait should be in a loop