moved adding event listener into the document.ready()