fix min/max portability