fix bug of wait