move the code to main.js