helper_minmax function

Helper function for minmax method.