small refactor in event-loop