use setImmediate to avoid stack size problems