refactoring controller and services