implemented environment detection