added several comments to the code