fixed a bug on max and min validation