add casts for std::min