Updated onTick method.