Move code to main.js