players spawning outside border

Ive made a moving border datapack for my server but when people log out and log back in and the border has moved they spawned back where they were outside of the border. I want to have them spawn inside the border when they join the server

Continue to help post