chapter 5 code (no exercises)