fix wait bug