diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp
index a9e372afe1258df42e30bdac51be4e2772ae63f5..37ea9d90461c75c25949352234426948254991c2 100644
--- a/src/core/PlumedMain.cpp
+++ b/src/core/PlumedMain.cpp
@@ -171,7 +171,10 @@ void PlumedMain::cmd(const std::string & word,void*val){
   std::vector<std::string> words=Tools::getWords(word);
   unsigned nw=words.size();
   if(nw==1) {
-    switch(word_map[word]) {
+    int iword=-1;
+    std::map<std::string, int>::const_iterator it=word_map.find(word);
+    if(it!=word_map.end()) iword=it->second;
+    switch(iword) {
       double d;
       case SETBOX:
         CHECK_INIT(initialized,word);