Added code for exercise 9.