Added untested min max code
Minor corrections