fixed bug in latency measurement