updated env detect method