Move script from html to js file