Added comments, improved code readability.