replacing nextTick with a timer