Game crashes while trying to run a function on an entity
I am trying to make a freeze breath that cast a ray, and if it hits a block or entity, it runs the according function. It works with blocks, and it seems that if there are no entities nearby, it doesn't crash, but when there is a volunteering villager nearby(or any entity), and I activate the freeze breath, I stop being able to interact with the world, the tick function doesn't run anymore, and entities don't move anymore. If I try to save and exit, the game freezes on the saving screen and I need to kill minecraft with the terminal. Here is the function for the raycast, which is called superpowered:freeze_breath_ray:
playsound minecraft:block.powder_snow.hit ambient @a ~ ~ ~ 5 1 execute if entity @s[distance=..6] unless entity @e[tag=!canFreeze,distance=..1.5] if block ~ ~ ~ #superpowered:can_freeze_through positioned ^ ^ ^0.5 run function superpowered:freeze_breath_ray execute unless block ~ ~ ~ #superpowered:can_freeze_through positioned ^ ^ ^ run function superpowered:freeze_hit_block execute as @e[tag=!canFreeze,distance=..1.5] run function superpowered:freeze_hit_entity```