Combine min and max to single func