automatic environment detection