implemented rest of chapter 9