refactoring the service layer