refactoring app.js