fix bug in event listener