added all code up to end of chapter 13.0