move app code into app.js