Exercise 4.5 resolved