Moving sript from index.html to main.js