fixing min to max for maxval