refactored service