fixed problem with setImmediate