rearranged functions in app.js