fix min max issue