Move JS code to main.js