added latency measurement