Reorganized app.js