Better env detection