Added Typeof to setImmediate check