stack with function min