Speeding up min_location and max_location