added all code up to (not including) chapter 9