rearrange some code in app.js & helpers.js