move script from html to js file