implement wait condition