Making arrays and object operations cleaner in app.js