use settimeout instead of setImmediate