diff --git a/src/PlumedMain.cpp b/src/PlumedMain.cpp
index d807fa2c8ea04455517576bf4bc910a66405a250..02ce20ffe25f5a9d688549be6b07fa7a3160dfe4 100644
--- a/src/PlumedMain.cpp
+++ b/src/PlumedMain.cpp
@@ -369,6 +369,10 @@ void PlumedMain::prepareDependencies(){
 // new/changed dependency (up to now, only useful for dependences on virtual atoms,
 // which can be dynamically changed).
 //
+
+// First switch off all actions
+  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();p++) (*p)->deactivate();
+
 // for optimization, an "active" flag remains false if no action at all is active
   active=false;
   for(unsigned i=0;i<pilots.size();++i){
@@ -432,9 +436,6 @@ void PlumedMain::performCalc(){
 // this is updating the MD copy of the forces
   atoms.updateForces();
 
-// Finally switch off all actions (they will be switched on at next step
-  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();p++) (*p)->deactivate();
-
 }
 
 void PlumedMain::load(std::vector<std::string> & words){