refactorred app.js