use setImmediate when available