Fix the average calculation