Changed enviroment detection method to allow for domains and hostnames