Exercise 3.9: finally done