Calculates average time