Use setImmediate instead of process.nextTick