minor bug fix in average calculations