controller.js optimizations