moved window.addEventListener from html to javascript