move the js code to main.js file