bug fix for broadcast and wait loop