How to safely co sleep with mobile babies?p

For any moms who co sleep with babies…what did you do when your baby was old enough to crawl to stop them from falling out of the bed? My baby wakes up from naps or in the morning and immediately starts trying to escape lmao. I Always make it in in time to stop them, but I’m always anxious when they’re sleeping that they’re going to get up and I’m going to be a second too late. I would just like to have something that I’ll know for sure they’ll be safe. and to say ahead of time, Ive never been able to successfully transfer them successfully from bed to crib, they always wakes up, we used to use pillows but now they just crawl over the them, and we had one of those rail things but it doesn’t work with our bed it won’t stay secure enough