fixed bug with calculation of avg time