finished chapter 18 example