Fixed bug in event listener