Fix issue with avg(function)