Moved script from index to main.js