refactoring domain and first subdomain check into new method