diff --git a/taxonomy_browser.module b/taxonomy_browser.module
index ec97c76..3340394 100644
--- a/taxonomy_browser.module
+++ b/taxonomy_browser.module
@@ -564,7 +564,7 @@ function taxonomy_browser_count_nodes($tids = array(), $operator = 'or', $depth
     if ($operator == 'or') {
       $str_tids = implode(',', call_user_func_array('array_merge', $descendant_tids));
 
-      $sql_count = 'SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} tn USING(nid) WHERE '. ($type_where ? $type_where .' AND ' : NULL) ."tn.tid IN ($str_tids) ORDER BY n.sticky DESC, n.title ASC";
+      $sql_count = 'SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} tn USING(vid) WHERE '. ($type_where ? $type_where .' AND ' : NULL) ."tn.tid IN ($str_tids) ORDER BY n.sticky DESC, n.title ASC";
     }
     else {
       $joins = '';
@@ -573,7 +573,7 @@ function taxonomy_browser_count_nodes($tids = array(), $operator = 'or', $depth
         $wheres[] = $type_where;
       }
       foreach ($descendant_tids as $index => $tids) {
-        $joins .= 'INNER JOIN {term_node} tn'. $index .' ON n.nid = tn'. $index .'.nid ';
+        $joins .= 'INNER JOIN {term_node} tn'. $index .' ON n.vid = tn'. $index .'.vid ';
         $wheres[] = 'tn'. $index .'.tid IN ('. implode(',', $tids) .')';
       }
       $sql_count = 'SELECT COUNT(n.nid) FROM {node} n '. $joins .' WHERE '. implode(' AND ', $wheres);
