(#2543) - fix call stack exceeded

we use this function a lot so it actually might, but merge it and I can open a pull fixing it