fixing event handling