refactored controllers.js