Refactor on app.js