diff --git a/src/graph/helper.cc b/src/graph/helper.cc
index 199e71fdea2d51e617546548dac8d46e4bc69e46..5cc7b0ed89a52315c564733dfcc6c3da5525201e 100644
--- a/src/graph/helper.cc
+++ b/src/graph/helper.cc
@@ -610,8 +610,15 @@ namespace hpp {
             inline nodeid_type nodeid (const GraspV_t& iG)
             {
               nodeid_type iGOH = iG[0];
-              for (index_t i = 1; i < nG; ++i)
-                iGOH += dims[i] * (iG[i]);
+              nodeid_type res;
+              for (index_t i = 1; i < nG; ++i) {
+                res = iGOH + dims[i] * (iG[i]);
+                if (res < iGOH) {
+                  hppDout (info, "Node ID overflowed. There are too many states...");
+                }
+                iGOH = res;
+                // iGOH += dims[i] * (iG[i]);
+              }
               return iGOH;
             }