diff --git a/ip2country.inc b/ip2country.inc
index 4a5a289..c80bc85 100644
--- a/ip2country.inc
+++ b/ip2country.inc
@@ -21,6 +21,7 @@
  *   Regional Internet Registry from which to get the data.
  *   Allowed values are afrinic, apnic, arin (default), lacnic, or ripe.
  */
+
 function ip2country_update_database($registry='arin') {
   $registry = drupal_strtolower(trim($registry));
 
@@ -49,6 +50,7 @@ function ip2country_update_database($registry='arin') {
 
   // Download data files from the chosen registry.
   $entries   = 0;
+  //$query = db_insert('ip2country');
   foreach ($ftp_urls as $ftp_file) {
     // Replace Registry source with chosen registry.
     $ftp_file = str_replace('ftp.ripe', 'ftp.' . $registry, $ftp_file);
@@ -64,6 +66,7 @@ function ip2country_update_database($registry='arin') {
     // Break the FTP file into lines.
     $lines = explode("\n", $txt);
     unset($txt);  // Free up memory.
+    $query = db_insert('ip2country')->fields(array('ip_range_first', 'ip_range_last', 'ip_range_length', 'country', 'registry'));
     foreach ($lines as $line) {
       // Trim each line for security.
       $line = trim($line, "\r\t \n");
@@ -86,18 +89,12 @@ function ip2country_update_database($registry='arin') {
       $range_length = (int) $parts[4];
 
       // Insert range into the DB.
-      db_insert('ip2country')->fields(array(
-                'ip_range_first'  => min($ip_start, $ip_end),
-                'ip_range_last'   => max($ip_start, $ip_end),
-                'ip_range_length' => $range_length,
-                'country'         => $country_code,
-                'registry'        => $owner_registry,
-        )
-      )->execute();
+      $query->values(array(min($ip_start, $ip_end), max($ip_start, $ip_end), $range_length, $country_code, $owner_registry));
       $entries++;
     }
+    $query->execute();
   }
 
   // Return record count in table.
   variable_set('ip2country_last_update', REQUEST_TIME);
   return $entries;
