added comments to function