Updated code regarding chapter 8