Added some comments to enhance code readability.