solve exercise 20.31