Improve next_event flow