Partial solution to exercise 5.15