finished exercise 10.5.6