works needavgmaxmin