Finished most of problem 7