Move event logic to its own class