function to find the max or min use defined yourself