diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp
index 48bce35e575bc69bfc3aa7b949daa1e3ef38f466..a6faa3460f5ccf476b2b77d1d10e9e1af67e718c 100644
--- a/src/core/PlumedMain.cpp
+++ b/src/core/PlumedMain.cpp
@@ -409,11 +409,6 @@ void PlumedMain::readInputWords(const std::vector<std::string> & words){
   else if(words[0]=="_SET_SUFFIX"){
     plumed_assert(words.size()==2);
     setSuffix(words[1]);
-  }
-  else if(words[0]=="RANDOM_EXCHANGES"){
-    exchangePatterns.setFlag(exchangePatterns.RANDOM);
-    // I convert the seed to -seed because I think it is more general to use a positive seed in input
-    if(words.size()>2&&words[1]=="SEED") {int seed; Tools::convert(words[2],seed); exchangePatterns.setSeed(-seed); }
   } else {
     std::vector<std::string> interpreted(words);
     Tools::interpretLabel(interpreted);
diff --git a/src/core/PlumedMain.h b/src/core/PlumedMain.h
index 9d45fd9dc06438eaf5bb488cf296bff2d1b8ab01..3d035399cec118d3bd7cb72e6a937cd3cba19f2e 100644
--- a/src/core/PlumedMain.h
+++ b/src/core/PlumedMain.h
@@ -271,6 +271,9 @@ public:
 /// This function allows to enforce active plumed when doing exchanges,
 /// thus fixing the bug.
   void resetActive(bool active);
+
+/// Access to exchange patterns
+  ExchangePatterns& getExchangePatterns(){return exchangePatterns;}
 };
 
 /////
diff --git a/src/generic/RandomExchanges.cpp b/src/generic/RandomExchanges.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eb62a88115a95e4c0572c0d416067f047a4cdf98
--- /dev/null
+++ b/src/generic/RandomExchanges.cpp
@@ -0,0 +1,71 @@
+/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+   Copyright (c) 2013 The plumed team
+   (see the PEOPLE file at the root of the distribution for a list of names)
+
+   See http://www.plumed-code.org for more information.
+
+   This file is part of plumed, version 2.0.
+
+   plumed is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   plumed is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with plumed.  If not, see <http://www.gnu.org/licenses/>.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "core/Action.h"
+#include "core/ActionRegister.h"
+#include "core/PlumedMain.h"
+#include "tools/Exception.h"
+#include "core/ExchangePatterns.h"
+
+using namespace std;
+
+namespace PLMD{
+namespace generic{
+
+//+PLUMEDOC GENERIC RANDOM_EXCHANGES
+/*
+Set random pattern for exchanges
+
+\par Examples
+
+*/
+//+ENDPLUMEDOC
+
+class RandomExchanges:
+  public Action
+{
+public:
+  static void registerKeywords( Keywords& keys );
+  RandomExchanges(const ActionOptions&ao);
+  void calculate(){}
+  void apply(){}
+};
+
+PLUMED_REGISTER_ACTION(RandomExchanges,"RANDOM_EXCHANGES")
+
+void RandomExchanges::registerKeywords( Keywords& keys ){
+  Action::registerKeywords(keys);
+  keys.add("optional","SEED","seed for random exchanges");
+}
+
+RandomExchanges::RandomExchanges(const ActionOptions&ao):
+Action(ao)
+{
+  plumed.getExchangePatterns().setFlag(ExchangePatterns::RANDOM);
+// I convert the seed to -seed because I think it is more general to use a positive seed in input
+  int seed=-1;
+  parse("SEED",seed);
+  if(seed>=0) plumed.getExchangePatterns().setSeed(-seed);
+}
+
+}
+}
+