fix for min, max and added avg function