update environment detection and export code