Added comments to help describe how it works.