diff --git a/alib2algo/src/arbology/exact/BoyerMooreHorspool.cpp b/alib2algo/src/arbology/exact/BoyerMooreHorspool.cpp
index 4c3b3058f42d3940366e6cb5ec3dbd0d9d134640..21f8c3a328c896562646b780838d53f9c3a63c27 100644
--- a/alib2algo/src/arbology/exact/BoyerMooreHorspool.cpp
+++ b/alib2algo/src/arbology/exact/BoyerMooreHorspool.cpp
@@ -44,12 +44,12 @@ std::set < unsigned > BoyerMooreHorspool::match ( const tree::PrefixRankedBarTre
 	while ( i + pattern.getContent ( ).size ( ) <= subject.getContent ( ).size ( ) ) {
 
 		 // index to the pattern
-		unsigned j = pattern.getContent ( ).size ( ) - 1;
+		int j = pattern.getContent ( ).size ( ) - 1;
 
 		 // offset to the subject
-		unsigned offset = i + j;
+		int offset = i + j;
 
-		while ( ( j > 0 ) && ( offset > 0 ) ) {
+		while ( ( j >= 0 ) && ( offset >= 0 ) ) {
 			if ( subject.getContent ( )[offset] == pattern.getContent ( )[j] ) {
 				 // match of symbol
 				offset = offset - 1;
@@ -64,7 +64,7 @@ std::set < unsigned > BoyerMooreHorspool::match ( const tree::PrefixRankedBarTre
 		}
 
 		 // match was found
-		if ( j == 0 ) occ.insert ( offset );
+		if ( j == -1 ) occ.insert ( offset );
 
 		 // shift heuristics
 		i += bcs[subject.getContent ( )[i + pattern.getContent ( ).size ( ) - 1]];
@@ -92,12 +92,12 @@ std::set < unsigned > BoyerMooreHorspool::match ( const tree::PrefixRankedBarTre
 		variablesSetting.clear();
 
 		 // index to the pattern
-		unsigned j = pattern.getContent ( ).size ( ) - 1;
+		int j = pattern.getContent ( ).size ( ) - 1;
 
 		 // offset to the subject
-		unsigned offset = i + j;
+		int offset = i + j;
 
-		while ( ( j > 0 ) && ( offset > 0 ) ) {
+		while ( ( j >= 0 ) && ( offset >= 0 ) ) {
 			if ( subject.getContent ( )[offset] == pattern.getContent ( )[j] ) {
 				 // match of symbol
 				offset = offset - 1;
@@ -105,24 +105,24 @@ std::set < unsigned > BoyerMooreHorspool::match ( const tree::PrefixRankedBarTre
 			} else if ( ( pattern.getContent ( )[j] == pattern.getVariablesBar ( ) ) && ( pattern.getBars ( ).count ( subject.getContent ( )[offset] )) ) {
 				 // else match of variable with subtree
 				offset = subjectSubtreeJumpTable[offset];
+				j = j - 2;
 
 				 // check nonlinear variable
-				if ( pattern.getNonlinearVariables ( ).count ( pattern.getContent ( )[ j - 1 ] ) ) {
-					auto setting = variablesSetting.find ( pattern.getContent ( )[ j - 1 ] );
+				if ( pattern.getNonlinearVariables ( ).count ( pattern.getContent ( )[ j + 1 ] ) ) {
+					auto setting = variablesSetting.find ( pattern.getContent ( )[ j + 1 ] );
 
 					if ( setting != variablesSetting.end ( ) && repeats.getContent ( )[ offset + 1 ].getSymbol ( ) != setting->second )
 						break;
 
-					variablesSetting.insert ( std::make_pair ( pattern.getContent ( )[ j - 1 ], repeats.getContent( )[ offset + 1 ].getSymbol ( ) ) );
+					variablesSetting.insert ( std::make_pair ( pattern.getContent ( )[ j + 1 ], repeats.getContent( )[ offset + 1 ].getSymbol ( ) ) );
 				}
-				j = j - 2;
 			} else {
 				break;
 			}
 		}
 
 		 // match was found
-		if ( j == 0 ) occ.insert ( offset );
+		if ( j == -1 ) occ.insert ( offset );
 
 		 // shift heuristics
 		i += bcs[subject.getContent ( )[i + pattern.getContent ( ).size ( ) - 1]];