changed all fmin to std::min
changed all fmin to std::min