Fixed incorrect end wait