fixed bug when switching environments