critical bugfix in wait script