refactored app.js

duplicate functions condensed