solve exercise 18.17