Move whois query into a helper function