Added comments to clean up the code