replace setImmediate with setTimeout(0)