How to improve my lightning arrows?

A few weeks ago, I asked about how to summon lightning an x amount of times at an arrow shot from a specific bow (I named it Chaos of Asraelax), only after it hits the ground (because execute at @e[type=arrow] run summon lightning_bolt will summon lightning every tick, and it doesn't even have to be an arrow shot from the player).
Someone answered it, and it kind of worked! Arrows shot from my bow will be tagged as chaos arrow and when they hit the ground, they will summon lightning 5 times. Here's the code for it (credits to mindoverflow, circusbaby23, and JohnPaulInso(Youtube) for contributing to this):

Declare objectives:

/scoreboard objectives add UseBow minecraft.used:bow
/scoreboard objectives add Summon1 dummy
/scoreboard objectives add Timer1 dummy

Command that gives bow:

give @p bow{CustomModelData:103,display:{Name:"[{\"text\":\"Chaos of\",\"color\":\"yellow\"},{\"text\":\" Asraelax\",\"color\":\"yellow\"}]",Lore:["{\"text\":\"An all purpose bow cursed by Asraelax\",\"color\":\"gray\",\"italic\":false}"]},Unbreakable:1,HideFlags:7}

First chain:

[r] execute at @a[scores={UseBow=1..},nbt={SelectedItem:{id:"minecraft:bow",Count:1b,tag:{CustomModelData:103,display:{Name:"[{\"text\":\"Chaos of\",\"color\":\"yellow\"},{\"text\":\" Asraelax\",\"color\":\"yellow\"}]"}}}}] run data merge entity @e[type=arrow,limit=1,sort=nearest,distance=..2] {Tags:["chaosarrow"]}
[c] execute as @a[scores={UseBow=1..}] at @e[type=arrow,tag=chaosarrow,nbt={inGround:1b},limit=1] run summon minecraft:armor_stand ~ ~ ~ {Tags:["chaos"],Invulnerable:1b,Invisible:1b}
[c] execute at @e[tag=chaosarrow,nbt={inGround:1b}] run scoreboard players remove @a UseBow 1
[c] kill @e[tag=chaosarrow,nbt={inGround:1b}]

Second chain:

[r] scoreboard players add @e[tag=chaos] TimerL 1
[c] execute as @e[tag=chaos,scores={TimerL=1}] at @s run summon minecraft:lightning_bolt
[c] execute as @e[tag=chaos,scores={TimerL=1}] at @s run scoreboard players add @s StrikeL 1
[c] execute as @e[tag=chaos,scores={TimerL=5}] at @s run scoreboard players set @s TimerL 0
[c] kill @e[tag=chaos,scores={StrikeL=5}]

As I've mentioned, this works pretty great, basically, it detects when you've used a bow, and tag all arrows near the bow with the tag chaos arrow. When the command detects an arrow with the tags chaos arrow and InGround, it summons an armor stand with tag chaos. Any armor stands with tag chaos will be struck by lightning 5 times, then killed.

Only one small downside. If there is an arrow near you, and you're holding the Chaos of Asraelax, it will ALSO tag the arrow, even though it wasn't shot from my bow, and summons lightning.

When mindoverflow posted this, they regarded that problem, but I just included it in as a feature, like I can summon a bunch of arrows, and then just stand near them and, chaos.

But is there a way to prevent this from happening? There are three answers to this.
Number one, no (say it in comments).
Number two, yes you'll only have to alter some of the above code.
Number three, yes there is a way but it is not compatible with the code above, and it requires an entirely new command setup.

Thanks for reading this through!


Solution 1:

Your third line will take away the score of players who used a bow only when that arrow hits the ground. The correct thing to do is to take away the score imediatly after the two first commands. Change your third line to:

/scoreboard players remove @a[scores={UseBow=1..}] UseBow 1