refactor app.js