move all event handling to one place