Corrected event handling