Added comments to improve code readability.