Added env detection