Refactor app.js