blocking emulation using recursive setTimeouts