fixed getNext and getPreviousLineIndex