app.js refactoring