<algorithm> needed for std::min