Refactoring on controller and repository