Finished exercise of chapter8