Exercise 4 solution