Include <algorithm> for std::min and std::max