Attempt to abstract logic to an event and event handler
Some code cleanup