added the solution for problem 5