fix incorrect event handling