--- a/src/statistics/Stats_window.cpp
+++ b/src/statistics/Stats_window.cpp
@@ -205,14 +205,17 @@ void Stats_window::set_selected_nodes(st
     // We fill the new selected containers
     // TODO : Use the tree instead of the list
     QTreeWidgetItemIterator it(_nodes_selected);
-    while (*it) {
+    for (; *it; it++) {
         if ((*it)->checkState(0) == Qt::Checked){
 	    Container *cont = _trace->search_container((*it)->text(0).toStdString());
+	    if (!cont) {
+		    cout << "didn't find container " << (*it)->text(0).toStdString() << endl;
+		    continue;
+	    }
             //cout << ((ContainerType *)cont->get_type())->get_name().to_string() << " " << ((ContainerType *)kind_of_container)->get_name().to_string() << endl;
 	    if (cont->get_type() == kind_of_container)
 	      _selected_containers.push_back(cont);
         }
-        it ++;
     }
     _number_of_selected_container = _selected_containers.size();
 
