small changes to code form

simplified event listener code