exercise 5.9 modified