Simplify sum and average