minmax bug fix