Better subdomain pulling/replacement logic