updates to chapter 5 code