Refactor command to service