updated detect env name logic 2