Added invironment detection