Added comments and indenting to the solution.