adding visited-node tracking