added some comments to clarify what I did