solved chap 6, exercise 8