partial work on problem 4.