Code cleanup in controller.js