fix some bugs in the env