refactored service creation to service factory