Refactoring app.js