--- C:/Documents and Settings/Christian/Skrivbord/community_tags-5.x-1.x-dev/community_tags/community_tags.module	Wed Aug 01 23:38:50 2007
+++ C:/Documents and Settings/Christian/Skrivbord/community_tags-5.x-1.x-dev/community_tags_fixed/community_tags.module	Thu Jan 03 11:36:48 2008
@@ -458,8 +458,18 @@
   if (isset($terms['tags'])) {
     $typed_input = $terms['tags'];
     unset($terms['tags']);
+	
+  	$node = node_load($nid);
+ 	$vids = community_tags_vids_for_node($node);
 
-    foreach ($typed_input as $vid => $vid_value) {
+	  $valid_vids = array();
+	  foreach ($typed_input as $vid => $vid_value) {
+		 if(in_array($vid,$vids)) {
+		 	$valid_vids[$vid] = $vid_value;
+	   }
+	  }
+
+    foreach ($valid_vids as $vid => $vid_value) {
       $typed_terms = is_array($vid_value) ? $vid_value : taxonomy_explode_tags($vid_value);
       foreach ($typed_terms as $typed_term) {
         // See if the term exists in the chosen vocabulary
