Placing a players head into an ender chest

Hey guys, i am developing a datapack and i want to place the players playerhead inside his ender chest with some custom nbt data. So far i have created a loot table file, that gives the player head and using these commands, i can place them inside the ender chest:

loot replace entity @e[type=item_frame,tag=head_getter,limit=1] container.0 loot namespace:player_head

data modify storage minecraft:menu head_item set from entity @e[type=item_frame,tag=head_getter,limit=1] Item
data modify storage minecraft:menu head_item.tag merge value {custom_data:{isMenu:1b,page:1,selection:4}}

item replace entity @s enderchest.25 from entity @e[type=item_frame,tag=head_getter,limit=1] container.0

Not sure if this ís actually the best way to do it, this just works, but the nbt data (custom_data) is not added to the item. How can i add that data? I thought about something like:

data modify entity @s EnderItems[{Slot:25b}].components.custom_data set value {isMenu:1b,page:1,selection:4}

but that doesnt work and i think the "path" changed in 1.21, but i am unsure about this.

Could someone help me with this? Maybe someone knows a better way to do it?

Continue to help post