improve environment detector