diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp
index 641c3eb0ab9c8427d078542af6411abc769b7f3a..73c8c994185c7355e95d25ec757811b29b6194af 100644
--- a/indra/llui/lltoolbarview.cpp
+++ b/indra/llui/lltoolbarview.cpp
@@ -80,52 +80,25 @@ bool LLToolBarView::load()
 	}
 	
 	// Add commands to each toolbar
-	// *TODO: factorize that code : tricky with Blocks though, simple lexical approach fails
-	LLCommandManager& mgr = LLCommandManager::instance();
-
 	if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft)
 	{
 		BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands)
 		{
-			LLCommandId* commandId = new LLCommandId(command);
-			if (mgr.getCommand(*commandId))
-			{
-				mToolbarLeft->addCommand(*commandId);
-			}
-			else 
-			{
-				llwarns	<< "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl;
-			}
+			addCommand(LLCommandId(command),mToolbarLeft);
 		}
 	}
 	if (toolbar_set.right_toolbar.isProvided() && mToolbarRight)
 	{
 		BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands)
 		{
-			LLCommandId* commandId = new LLCommandId(command);
-			if (mgr.getCommand(*commandId))
-			{
-				mToolbarRight->addCommand(*commandId);
-			}
-			else 
-			{
-				llwarns	<< "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl;
-			}
+			addCommand(LLCommandId(command),mToolbarRight);
 		}
 	}
 	if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom)
 	{
 		BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands)
 		{
-			LLCommandId* commandId = new LLCommandId(command);
-			if (mgr.getCommand(*commandId))
-			{
-				mToolbarBottom->addCommand(*commandId);
-			}
-			else 
-			{
-				llwarns	<< "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl;
-			}
+			addCommand(LLCommandId(command),mToolbarBottom);
 		}
 	}
 	return true;
@@ -179,6 +152,21 @@ bool LLToolBarView::hasCommand(const LLCommandId& commandId) const
 	return has_command;
 }
 
+bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar)
+{
+	LLCommandManager& mgr = LLCommandManager::instance();
+	if (mgr.getCommand(command))
+	{
+		toolbar->addCommand(command);
+	}
+	else 
+	{
+		llwarns	<< "Toolbars creation : the command " << command.name() << " cannot be found in the command manager" << llendl;
+		return false;
+	}
+	return true;
+}
+
 void LLToolBarView::draw()
 {
 	static bool debug_print = true;
diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h
index 0f16b89ecc81421bc8c2c434e6d3be639dce65d2..208660da8e3663fdda85dc33d01585fa073f3110 100644
--- a/indra/llui/lltoolbarview.h
+++ b/indra/llui/lltoolbarview.h
@@ -78,6 +78,7 @@ class LLToolBarView : public LLUICtrl
 private:
 	// Loads the toolbars from the existing user or default settings
 	bool	load();	// return false if load fails
+	bool	addCommand(const LLCommandId& commandId, LLToolBar*	toolbar);
 
 	// Pointers to the toolbars handled by the toolbar view
 	LLToolBar*	mToolbarLeft;