environment detection bugfix