bug fix for the minmax