setImmediate fix for recursion overflow on large datasets