updated process.nextTick to setImmediate