Rewritten event handling