Solution to exercise 2.22