finished the rewrite of enviroment