handle stacks correctly