diff --git a/modules/mol/alg/src/local_dist_test.cc b/modules/mol/alg/src/local_dist_test.cc
index cea1ea47d1e37140b7920814e27e5aa830388457..2d97aa915587805c6729327d22320e7db25c7dc3 100644
--- a/modules/mol/alg/src/local_dist_test.cc
+++ b/modules/mol/alg/src/local_dist_test.cc
@@ -1,3 +1,4 @@
+#include <ost/log.hh>
 #include <ost/mol/mol.hh>
 #include "local_dist_test.hh"
 
@@ -117,6 +118,14 @@ Real LocalDistTest(const EntityView& mdl, const EntityView& ref,
                    Real cutoff, Real max_dist)
 {
   ResidueViewList ref_residues=ref.GetResidueList();
+  if (!mdl.GetResidueCount()) {
+	LOG_WARNING("model structures doesn't contain any residues");
+	return 0.0;	
+  }
+  if (ref_residues.empty()) {
+	LOG_WARNING("reference structures doesn't contain any residues");
+	return 0.0;	
+  }
   ChainView mdl_chain=mdl.GetChainList()[0];  
   // Residues with symmetric side-chains require special treatment as there are 
   // two possible ways to name the atoms. We calculate the overlap with the