Simplified the average computation.