Fix latency calculation