move event listener to js file