Exercise 9.14 done my way