Exercise 3.21 resolved