homework 4: exercise 6