Added some comments to make my code easier to understand