Finalized the solutions for problem 2