begins refactoring app.js