finished writing hw7.  Not tested.