refactoring angularjs controllers.