use a setImmediate emulation in browsers