Changed fmin to use max