Fix the Average function