Added a potential solution for the third problem.