Refactored to create the domtest function