```\nif (\_purchased[delegation.holder] > 0) {\n    \_isPurchased[delegationId] = true;\n    if (\_purchased[delegation.holder] > delegation.amount) {\n        \_purchased[delegation.holder] -= delegation.amount;\n    } else {\n        \_purchased[delegation.holder] = 0;\n    }\n} else {\n    \_isPurchased[delegationId] = false;\n}\n```\n