refactoring with service