remove ifFound because db->fetch() returns nullptr if item not found. make nodeCount local instead of class member variable. use std::ref() instead of raw pointers in callback to visitNodes.