Revised exercise 5.2