calculate average time