std::min and max to remove VS errors