diff --git a/github_widget.module b/github_widget.module
index f31860b..f033174 100755
--- a/github_widget.module
+++ b/github_widget.module
@@ -70,12 +70,21 @@ function github_widget_node_delete($node) {
  */
 function github_widget_node_update($node) {
   $github_widget_node_types = variable_get('github_widget_type_filters', array());
-  if ($github_widget_node_types[$node->type]) {
-    if (!empty($node->github_repo_name) && !empty($node->github_username)) {
+  if ($github_widget_node_types[$node->type] == $node->type && !empty($node->github_repo_name) && !empty($node->github_username)) {
+    if (db_query('SELECT username from {github_widget} where nid = :nid', array(':nid' => $node->nid))->fetchObject()) {
       db_update('github_widget')
-      ->fields(array('repo' => $node->github_repo_name, 'username' => $node->github_username))
-      ->condition('nid', $node->nid)
-      ->execute();
+        ->fields(array('repo' => $node->github_repo_name, 'username' => $node->github_username))
+        ->condition('nid', $node->nid)
+        ->execute();
+    }
+    else {
+      db_insert('github_widget')
+		    ->fields(array(
+			    'nid' => $node->nid,
+			    'repo' => $node->github_repo_name,
+			    'username' => $node->github_username,
+		    ))
+		    ->execute();
     }
   }
 }
