working version
switch to nextTick