Use setImmediate if it exists instead of process.nextTick