update Max and Min functions so that comparing a number with undefined will return the number