Replacing process.nextTick with setImmediate to solve Maximum call stack size exceeded error