update the interface for the two first function (min and max)
add boundary check