add minmax function for scalars