restored to chapter 4 code