Finished exercise 2 in Chapter 5