If your code looks like this in pseudo code:
function do:
if (pool has mymoney = true)
split(mymoney)
pool has mymoney = false
By repeatedly calling that function, you have sort of a race condition where you are allowed to spend your money twice, trice, ... ad infitum.
Fix is simple, reverse two operations:
function do:
if (pool has mymoney = true)
pool= pool - mymoney // 2
split(mymoney) //1