Improve min/max computation