added the solution for problem 2