patched while-loop event flow