utility function for returning max