Remove duplicate logic from ServiceFactory