implemented nextIndex and previousIndex