added comments to some of the code