added cast to function_to_min