refactor app.js and controllers.js