diff --git a/src/core/ActionAtomistic.cpp b/src/core/ActionAtomistic.cpp
index a8b35d513c13180e397a3137df42346476c9dffc..e798d4a415342382151aaba9c4d1bd75c23a2dde 100644
--- a/src/core/ActionAtomistic.cpp
+++ b/src/core/ActionAtomistic.cpp
@@ -71,7 +71,7 @@ void ActionAtomistic::requestAtoms(const vector<AtomNumber> & a){
   clearDependencies();
   unique.clear();
   for(unsigned i=0;i<indexes.size();i++){
-    plumed_massert(indexes[i].index()<n,"atom out of range");
+    if(indexes[i].index()>=n) error("atom out of range");
     if(atoms.isVirtualAtom(indexes[i])) addDependency(atoms.getVirtualAtomsAction(indexes[i]));
 // only real atoms are requested to lower level Atoms class
     else unique.insert(indexes[i]);