change nextTick to setImmediate