Reorganizing app.js file