finished exercise 4 of chap 11 (whole book)