fixed a min/max error