solve exercise 18.22