fix pending wait bug