Improved Exercise 10 (Chapter 2)