Added code to chapter 3