fixed code for hw7 problem 5