updating with rest of problem 2