recursive find min max