solved chapter 6 exercise