include <algorithm> wherever using std::min or std::max