stack with min function