I added some additional comments to the code, I also formatted it a little nicer