diff --git a/src/dgraph/pool.cpp b/src/dgraph/pool.cpp
index 8b4c94ad52349845702e1712392d29c7158383c6..d1c442258ec7f08459aa0adb52e71d835fa0a887 100644
--- a/src/dgraph/pool.cpp
+++ b/src/dgraph/pool.cpp
@@ -60,7 +60,9 @@ PoolStorage::
   dgDEBUGIN(15);
 
   for( Entities::iterator iter=entityMap.begin (); iter!=entityMap.end ();
-       iter++)
+       // Here, this is normal that the next iteration is at the beginning
+       // of the map as deregisterEntity remove the element iter from the map.
+       iter=entityMap.begin())
     {
       dgDEBUG(15) << "Delete \""
 		   << (iter->first) <<"\""<<std::endl;