added some code from chapter 1