Fix traversal referring to -1th element on stack