Sipmle script. Rate of fire. BUG

Here a script on rate of fire.
But there was a bug after get on the purpose rate of fire increases indefinitely.
How to correct? Help please.

local function HookEntityTakeDamage(victim, dmg)
	if IsValid(dmg:GetAttacker()) and dmg:GetAttacker():IsPlayer() then
		local weapon = dmg:GetAttacker():GetActiveWeapon()
		if IsValid(weapon) and weapon.Primary and weapon.Primary.Delay then
			weapon.Primary.Delay = weapon.Primary.Delay/1.5

hook.Add("EntityTakeDamage", "hook_name", HookEntityTakeDamage)

yeah, that’s how it’s supposed to work since you didn’t set a max ammount of fire rate

Whether it is possible to correct it?