made changes in latency calculation