Committing exercise 9 from chapter6