fixed false test condition if index exists.