finished answer to problem 3