added the solution for problem 3