app.js refactor