Clean up code by event model