will check later, thanks for update.
"math.abs(toAbsorb - totalInsertedAmount) > tol" is always TRUE, if totalInsertedAmount equals zero, while toAbsorb is greater than zero but smaller than 0.1.
local tol = math.max(0.01 * toAbsorb, 0.001) just sets thi MINIMUM of tol to 0.001
so checking those numbers on the printouts, i.e. 0.011666~ the calculation was
if (0.011666 - 0) > 0.001 then...
so it ALWAYS prints, when (0.01*toAbsorb) is SMALLER than 0.001, which means on all cases where toAbsorb < 0.1 while totalInsertedAmount is 0 (donno why this might happen, but the prints show all "... and 0 inserted")