Exercise 3.5 resolved