added environment detection for debug and email