added comments to functionality