update latency function