Did some refactoring on all the code in the app.js file