Exercise 3.27 resolved