Completed exercise 6 in HW05.