fixing the defect in re-indexing where it is moving forward the cursor by one in checking a condition