Added code for Exercise 9.