made getDomain more robust