solve exercise 31.12