Changing gamemode on which dimension the player is in [Solved]

I need it so whenever a player enters "pocket_dimension:pocket_dimension" they are changed into survival mode. but when they reenter "minecraft:overworld" they go into adventure mode.

all i have is this code from a reddit thread, but its for command blocks and id rather it be in datapack form

execute as @a[gamemode=creative] at @s unless dimension minecraft:overworld run gamemode survival

Continue to help post