moving js code from app.js to main.js