correct calculation of minmax of a column