revised chapter 5 and 6, started on chapter 7