updated environment detection