Simplified in_domains code (got rid of closure).