stack with min() function