Finish most of problem 2