exercise 4.11 a new implementation of environment