rewrite the controller to use module in angular