Is the index significant to restore the selection? IMHO you should compare dir instead.