Custom Data predicate problems

Hai! I'm having some trouble with detecting custom data using predicates. I have a custom rarity system for melee and ranged weapons, which I'm trying to change bow damage with using custom enchantments. For some reason, the predicates only pass if the rarity tag is the only custom data the bow has. The custom data predicate kinda looks like this: ("minecraft: custom_data": {"legendary": true}). It works, but only if the bow doesn't have any custom data besides "legendary: 1b"
Continue to help post