Auto min/max detection added