implementing stack, min_stack, max_stack