Refactored controllers in app.js