added enviroment switch function