fix min/max issue