Finalized solutionfor problem 38