diff --git a/alib2algo/src/grammar/properties/NullableNonterminals.h b/alib2algo/src/grammar/properties/NullableNonterminals.h
index d0446cfa6afee96f32795f12323e6a67dd1f110e..5c6472de999369075ae499a42f80418ed7b48062 100644
--- a/alib2algo/src/grammar/properties/NullableNonterminals.h
+++ b/alib2algo/src/grammar/properties/NullableNonterminals.h
@@ -47,11 +47,15 @@ ext::set<SymbolType> NullableNonterminals::getNullableNonterminals(const T& gram
 	Ni.push_back(ext::set<SymbolType>{ });
 	int i = 1;
 
+	auto testCallback = [ & ] ( const SymbolType & symb ) {
+		return Ni.at ( i - 1 ).count ( symb );
+	};
+
 	while(true) {
 		Ni.push_back(ext::set<SymbolType>{ });
 		for ( const auto & rule : rawRules ) {
 			for(const auto& rhs : rule.second) {
-				if(rhs.size() == 0 || std::all_of(rhs.begin(), rhs.end(), [Ni, i](const SymbolType& symb){return Ni.at(i-1).count(symb);})) {
+				if ( rhs.size ( ) == 0 || std::all_of ( rhs.begin ( ), rhs.end ( ), testCallback ) ) {
 					Ni.at(i).insert(rule.first);
 				}
 			}
diff --git a/alib2algo/src/grammar/properties/ProductiveNonterminals.h b/alib2algo/src/grammar/properties/ProductiveNonterminals.h
index b70b7077a0191664a54a6e07a4b0f47d6548b174..f7df0a21b5d243d5e7a37ffc41d56869668856f8 100644
--- a/alib2algo/src/grammar/properties/ProductiveNonterminals.h
+++ b/alib2algo/src/grammar/properties/ProductiveNonterminals.h
@@ -42,15 +42,17 @@ ext::set<SymbolType> ProductiveNonterminals::getProductiveNonterminals( const T
 
 	int i = 1;
 
+	auto testCallback = [ & ] ( const SymbolType & symbol ) {
+		return Ni.at ( i - 1 ).count ( symbol ) || grammar.getTerminalAlphabet ( ).count ( symbol );
+	};
+
 	// 2.
 	while( true ) {
 		Ni.push_back( Ni.at( i - 1 ) );
 
 		for( const auto & rule : rawRules ) {
 			for( const auto & rhs : rule.second ) {
-				if( std::all_of( rhs.begin( ), rhs.end( ), [ i, Ni, grammar ]( const SymbolType & symbol ) -> bool {
-					return Ni.at( i - 1 ) . count( symbol ) || grammar.getTerminalAlphabet( ). count( symbol );
-				} ) )
+				if( std::all_of( rhs.begin( ), rhs.end( ), testCallback ) )
 					Ni.at( i ).insert( rule.first );
 			}
 		}
diff --git a/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.h b/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.h
index c815ce14d810eaaf1878129eb4d5b7c0321d396e..68697b0ddff0dadc9f35ebf943a29a4c1554c904 100644
--- a/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.h
+++ b/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.h
@@ -59,12 +59,15 @@ T UnproductiveSymbolsRemover::remove( const T & grammar ) {
 	auto rawRules = grammar::RawRules::getRawRules ( grammar );
 
 	const ext::set<SymbolType> & terminals = ret.getTerminalAlphabet( );
+
+	auto testCallback = [ & ]( const SymbolType & symbol ) {
+		return Nt.count( symbol ) || terminals.count( symbol );
+	};
+
 	for( const auto & rule : rawRules ) {
 		if( Nt.count( rule.first ) ) {
 			for( const auto & rhs : rule.second ) {
-				if( all_of( rhs.begin( ), rhs.end( ), [ Nt, terminals ]( const SymbolType & symbol ) {
-						return Nt.count( symbol ) || terminals.count( symbol );
-				} ) )
+				if( all_of( rhs.begin( ), rhs.end( ), testCallback) )
 				grammar::AddRawRule::addRawRule ( ret, rule.first, rhs );
 			}
 		}
diff --git a/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h b/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h
index b7b91e19ccf1b71c8effeccaf0a9cd1582385e11..24c07b71d3b019b04ee1f7cdbce9f07870bbaa5d 100644
--- a/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h
+++ b/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h
@@ -61,13 +61,15 @@ T UnreachableSymbolsRemover::remove( const T & grammar) {
 
 	auto rawRules = grammar::RawRules::getRawRules ( grammar );
 
+	auto testCallback = [ & ]( const SymbolType & symb ) -> bool {
+		return Vt.count( symb );
+	};
+
 	// A->\alpha: if A \in N' and \alpha in V_i*, then A->\alpha in P
 	for( const auto & rule : rawRules ) {
 		if( newNonTerminals.count( rule.first ) ) {
 			for( const auto& rhs : rule.second ) {
-				if( all_of( rhs.begin( ), rhs.end( ), [ Vt ]( SymbolType const& symb ) -> bool {
-					return Vt.count( symb );
-				} ) )
+				if( all_of( rhs.begin( ), rhs.end( ), testCallback ) )
 				grammar::AddRawRule::addRawRule ( ret, rule.first, rhs );
 			}
 		}