Exercise 6 solution