added comments to each function