restructure app.js