Update max and min functions using the foldl1 function