Make the implementation slightly more clear, and add some comments to explain the solution.