Updated to work with subdomains