Refactoring of controller.js completed