fixed recursive setTick problem: now using setImmediate instead