Added environment detection