try nextTick rather than setImmediate