diff --git a/alib2algo/src/stringology/indexing/PositionHeapNaive.h b/alib2algo/src/stringology/indexing/PositionHeapNaive.h
index 71d40b0e537f90a194b18f5c8c1e89c75034f9b0..e523eedb2701987834ce64141dcfb8a770049f23 100644
--- a/alib2algo/src/stringology/indexing/PositionHeapNaive.h
+++ b/alib2algo/src/stringology/indexing/PositionHeapNaive.h
@@ -47,7 +47,7 @@ indexes::PositionHeap < SymbolType > PositionHeapNaive::construct ( const string
 		unsigned k = i - 1;
 		std::trie < SymbolType, unsigned > * n = & trie;
 
-		while ( k < w.getContent ( ).size ( ) && n->getChildren ( ).count ( w.getContent ( )[k] ) )
+		while ( n->getChildren ( ).count ( w.getContent ( )[k] ) )
 			n = & n->getChildren ( ).find ( w.getContent ( )[k++] )->second;
 
 		unsigned node = w.getContent ( ).size ( ) - i + 1;
diff --git a/alib2algo/src/stringology/indexing/SuffixTrieNaive.h b/alib2algo/src/stringology/indexing/SuffixTrieNaive.h
index 9d2b0a668f3d628401fb6850e47849fd33a95988..02ea1a1899035bcbc529e20c53b71132d0524e9f 100644
--- a/alib2algo/src/stringology/indexing/SuffixTrieNaive.h
+++ b/alib2algo/src/stringology/indexing/SuffixTrieNaive.h
@@ -46,7 +46,7 @@ indexes::SuffixTrie < SymbolType > SuffixTrieNaive::construct ( const string::Li
 		std::trie < SymbolType, std::variant < void, unsigned > > * n = & trie;
 
 		 // inlined slow_find_one from MI-EVY lectures
-		while ( k < w.getContent ( ).size ( ) && n->getChildren ( ).count ( w.getContent ( )[k] ) )
+		while ( n->getChildren ( ).count ( w.getContent ( )[k] ) )
 			n = & n->getChildren ( ).find ( w.getContent ( )[k++] )->second;
 
 		for ( ; k < w.getContent ( ).size ( ); k++ ) {