Refactor the app.js