refactor to app.js