add function max and min