diff --git a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.h b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.h
index 64289f293f01e74ab668f239391a6e3a5f9842b9..5a71ed75c566715a353066d74b82d9767e6bcce7 100644
--- a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.h
+++ b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkov.h
@@ -10,6 +10,7 @@
 
 #include <alib/set>
 #include <alib/variant>
+#include <alib/algorithm>
 
 #include <global/GlobalData.h>
 
@@ -46,14 +47,6 @@ private:
 		return common::ranked_symbol < SymbolType, RankType > ( symbol.getSymbol ( ).first, symbol.getRank ( ) );
 	}
 
-	template < class SymbolType, class RankType >
-	static bool isSubstSymbolPresent ( const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & container, const TAlphabet < SymbolType, RankType > & substAlphabet ) {
-		ext::vector < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > intersection;
-		std::set_intersection ( container.begin ( ), container.end ( ), substAlphabet.begin ( ), substAlphabet.end ( ), std::back_inserter ( intersection ) );
-		return intersection.size ( ) > 0;
-	}
-
-
 public:
 	/**
 	 * Implements conversion of the regular tree expressions to a real-time height-deterministic pushdown automaton usign algorithm similar to Glushkov's method of neighbours.
@@ -87,7 +80,7 @@ automaton::NPDA < ext::variant < common::ranked_symbol < SymbolType, RankType >,
 		followSet.insert ( std::make_pair ( symbol, rte::GlushkovFollow::follow ( indexedRTE, symbol, substMapTree ) ) );
 
 	/* check for exceptions -> there must be NO substitution symbol in first set */
-	if ( isSubstSymbolPresent ( firstSet, indexedRTE.getSubstitutionAlphabet ( ) ) )
+	if ( ! ext::excludes ( firstSet.begin ( ), firstSet.end ( ), indexedRTE.getSubstitutionAlphabet ( ).begin ( ), indexedRTE.getSubstitutionAlphabet ( ).end ( ) ) )
 		throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in the first set" );
 	/* check end */
 
@@ -95,7 +88,7 @@ automaton::NPDA < ext::variant < common::ranked_symbol < SymbolType, RankType >,
 	for ( const std::pair < const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType >, ext::set < GlushkovFollow::TFollowTuple < SymbolType, RankType > > > & kv : followSet )
 		for ( const GlushkovFollow::TFollowTuple < SymbolType, RankType > & followTuple : kv.second ) // TFollowTuple = vector < set < ranked_symbol > >
 			for ( const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & followTupleElem : followTuple )
-				if ( isSubstSymbolPresent ( followTupleElem, indexedRTE.getSubstitutionAlphabet ( ) ) )
+				if ( ! ext::excludes ( followTupleElem.begin ( ), followTupleElem.end ( ), indexedRTE.getSubstitutionAlphabet ( ).begin ( ), indexedRTE.getSubstitutionAlphabet ( ).end ( ) ) )
 					throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in a follow set" );
 	/* check end */
 
diff --git a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.h b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.h
index 587df49cc9689fa8156bf2aeb3335c9be1328c67..fcdc55877ceee60ab14d8ffe671525925fcfe3ca 100644
--- a/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.h
+++ b/alib2algo/src/rte/convert/ToPostfixPushdownAutomatonGlushkovNaive.h
@@ -35,13 +35,6 @@ class ToPostfixPushdownAutomatonGlushkovNaive {
 		return common::ranked_symbol < SymbolType, RankType > ( symbol.getSymbol ( ).first, symbol.getRank ( ) );
 	}
 
-	template < class SymbolType, class RankType >
-	static bool isSubstSymbolPresent ( const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & container, const ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > & substAlphabet ) {
-		ext::vector < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > intersection;
-		std::set_intersection ( container.begin ( ), container.end ( ), substAlphabet.begin ( ), substAlphabet.end ( ), std::back_inserter ( intersection ) );
-		return intersection.size ( ) > 0;
-	}
-
 public:
 	/**
 	 * Implements conversion of the regular tree expressions to a real-time height-deterministic pushdown automaton usign algorithm similar to Glushkov's method of neighbours.
@@ -74,13 +67,14 @@ automaton::NPDA < ext::variant < common::ranked_symbol < SymbolType, RankType >,
 		followSet.insert ( std::make_pair ( symbol, rte::GlushkovFollowNaive::follow ( indexedRTE, symbol ) ) );
 
 	 /* check for exceptions -> there must be NO substitution symbol in first or follow sets */
-	if ( isSubstSymbolPresent ( firstSet, indexedRTE.getSubstitutionAlphabet ( ) ) )
+	if ( ! ext::excludes ( firstSet.begin ( ), firstSet.end ( ), indexedRTE.getSubstitutionAlphabet ( ).begin ( ), indexedRTE.getSubstitutionAlphabet ( ).end ( ) ) )
 		throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in the first set" );
 
 	for ( const auto & kv : followSet )
 		for ( const auto & followTuple : kv.second )
-			if ( isSubstSymbolPresent ( ext::set < common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > > ( followTuple.begin ( ), followTuple.end ( ) ), indexedRTE.getSubstitutionAlphabet ( ) ) )
-				throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in a follow set" );
+			for ( const common::ranked_symbol < ext::pair < SymbolType, unsigned >, RankType > & followTupleElem : followTuple )
+				if ( indexedRTE.getSubstitutionAlphabet ( ).count ( followTupleElem ) )
+					throw exception::CommonException ( "GlushkovRTE: Substitution symbol appeared in a follow set" );
 
 	/* check end */