how do i check if NBT data exists?

i have a McFunction file that reads as follows:

$execute as @s at @s run $(command1)
$execute as @s at @s run $(command2)
etc...
$execute as @s at @s run $(command999)```
but this doesn't work, since most of the time most of these aren't present in the NBT data of the entity, and whenever this happens Minecraft throws a tantrum.
How do i check if the key-value pair is actually there before running the command? Is there any way to avoid the issue completely and write this in a better way?
Continue to help post