fixed the event handlers