Added comments to the code to create some clarity