Finished Chapter 7 exercise