IMplment first version of max and min