added code for problem 2