replace process.nextTick with setTimeout