how latency works