added minMax helper