diff --git a/mail2og.module b/mail2og.module
index 55aff9d..8dcd6c4 100644
--- a/mail2og.module
+++ b/mail2og.module
@@ -195,7 +195,7 @@ function mail2og_find_email_address($email, $cck_field = null) {
     // get the relevant database information for this field
     $db_info = content_database_info($field);
     // look for this email address in the correct col
-    $result = db_result(db_query('SELECT field.nid FROM '. $db_info['table'] .' field WHERE '. $db_info['columns']['value']['column'] .'  = "%s"', $email));
+    $result = db_result(db_query('SELECT field.nid FROM %s field WHERE %s = "%s"', $db_info['table'], $db_info['columns']['value']['column'], $email));
     if ($result) {
       return node_load($result);
     }
@@ -216,7 +216,7 @@ function mail2og_administration_form() {
     '#type' => 'select',
     '#multiple' => true,
     '#title' => t('Enable mail2og on'),
-    '#options' =>  array_merge(array(0 => t('No groups'), 1 => t('All groups')), og_all_groups_options()),
+    '#options' =>  array(0 => t('No groups'), 1 => t('All groups')) + og_all_groups_options(),
     '#default_value' => variable_get('mail2og_enabled_groups', 0),
     '#description' => t('Select the groups you want to enable mail2og on. Default is all')
   );
@@ -357,7 +357,7 @@ function mail2og_mailhandler(&$node, $result, $i, $header, $mailbox) {
   }
 
   // now we need to look for the emailbox name to see if it belongs to a group
-  if (! $group = mail2og_find_email_address($header->toaddress) ) {
+  if (! $group = mail2og_find_email_address($header->to[0]->mailbox . '@' . $header->to[0]->host) ) {
     return;
   }
 
@@ -736,4 +736,4 @@ function theme_mail2og_block_display_email_info($group, $email) {
   $html = array();
   $html[] = t('You can post to this group by sending an email to %email', array('%email' => $email));
   return implode('<br/>', $html);
-}
\ No newline at end of file
+}
