diff --git a/eprints1.pl b/eprints1.pl
index 2604c9276ecc5da7d12d3cdbdf2b5c2726cb25a4..64880a0e26e4ce25b99ecab6a7721151f3379ab7 100755
--- a/eprints1.pl
+++ b/eprints1.pl
@@ -57,8 +57,8 @@ a.k.a. NBNs, as a proxy of attached applications like "eprints".
 
 use strict;
 
-use DBI;
-use DBD::mysql;
+# use DBI;
+# use DBD::mysql;
 use JSON -convert_blessed_universally;
 use Redis;
 
@@ -89,6 +89,8 @@ use IRMA::urn::nbn::at;
 
 use Univie::Utheses::Container;
 
+use Alma::MARC_Extractor;
+
 # TODO: make this configurable too!
 my $config_fnm= '/etc/irma/eprints.json';
 
@@ -5614,6 +5616,9 @@ sub export_migration_data
   print __LINE__, " get data from alma.marc\n";
   my @marc_fields= qw(ac_number mms_id fetched lib_code);
   my @marc_extra_fields= qw(marc_record ts_fetched);
+
+  my $mex= Alma::MARC_Extractor->new(\@marc_fields);
+
   {
     my $db_marc= get_marc_db($cnf);
     my $col_marc= $db_marc->get_collection('alma.marc');
@@ -5641,61 +5646,7 @@ sub export_migration_data
 
       $rec->{marc_record}= 'found';
       $rec->{ts_fetched}= Util::ts::ts_ISO_gmt($marc->{fetched});
-      foreach my $f (@marc_fields) { $rec->{$f}= $marc->{$f}; }
-
-      my $mrd= $marc->{xmlref}->{records}->[0]->{record}->[0]->{recordData}->[0]->{record}->[0];
-      unless (defined ($mrd))
-      {
-        $rec->{marc_record}= 'marc_data_not_found';
-        next MARC;
-      }
-      $rec->{marc_record}= 'marc_data_found';
-
-      # print __LINE__, " mrd: ", Dumper($mrd);
-      my ($df_urn, $val_urn, $df_doi, $val_doi, $df_othes, $val_othes, $df_utheses, $val_utheses);
-
-      foreach my $cf (@{$mrd->{controlfield}})
-      {
-        if ($cf->{tag} eq '005')
-        {
-          $rec->{ts_marc}= $cf->{content};
-        }
-      }
-
-      foreach my $df (@{$mrd->{datafield}})
-      {
-        foreach my $sf (@{$df->{subfield}})
-        {
-          if ($sf->{content} =~ m#urn:nbn#)
-          {
-            $df_urn= join(':', (map { $df->{$_} } qw(tag ind1 ind2)), $sf->{code});
-            $val_urn= $sf->{content};
-          }
-          elsif ($sf->{content} =~ m#10\.25365#)
-          {
-            $df_doi= join(':', (map { $df->{$_} } qw(tag ind1 ind2)), $sf->{code});
-            $val_doi= $sf->{content};
-          }
-          elsif ($sf->{content} =~ m#othes\.univie#)
-          {
-            $df_othes= join(':', (map { $df->{$_} } qw(tag ind1 ind2)), $sf->{code});
-            $val_othes= $sf->{content};
-          }
-          elsif ($sf->{content} =~ m#utheses\.univie#)
-          {
-            $df_utheses= join(':', (map { $df->{$_} } qw(tag ind1 ind2)), $sf->{code});
-            $val_utheses= $sf->{content};
-          }
-        }
-      }
-      $rec->{ df_urn}=      $df_urn;
-      $rec->{val_urn}=     $val_urn;
-      $rec->{ df_doi}=      $df_doi;
-      $rec->{val_doi}=     $val_doi;
-      $rec->{ df_othes}=    $df_othes;
-      $rec->{val_othes}=   $val_othes;
-      $rec->{ df_utheses}=  $df_utheses;
-      $rec->{val_utheses}= $val_utheses;
+      $mex->extract_identifiers($marc, $rec);
     }
   }
 
diff --git a/lib/Alma/MARC_Extractor.pm b/lib/Alma/MARC_Extractor.pm
new file mode 100644
index 0000000000000000000000000000000000000000..1cfe8be7442ef4872e7dc55ecad667b46f67392d
--- /dev/null
+++ b/lib/Alma/MARC_Extractor.pm
@@ -0,0 +1,87 @@
+
+package Alma::MARC_Extractor;
+
+use strict;
+
+sub new
+{
+  my $class= shift;
+  my $fields= shift;
+
+  my $self=
+  {
+    fields => $fields,
+  };
+
+  bless ($self, $class);
+  $self;
+}
+
+sub extract_identifiers
+{
+  my $self= shift;
+
+  my $marc= shift; # MARC record to select data from
+  my $rec= shift;  # record to fill extracted data into
+
+  foreach my $f (@{$self->{fields}}) { $rec->{$f}= $marc->{$f}; }
+
+  my $mrd= $marc->{xmlref}->{records}->[0]->{record}->[0]->{recordData}->[0]->{record}->[0];
+  unless (defined ($mrd))
+  {
+    $rec->{marc_record}= 'marc_data_not_found';
+    next MARC;
+  }
+  $rec->{marc_record}= 'marc_data_found';
+
+  # print __LINE__, " mrd: ", Dumper($mrd);
+  my ($df_urn, $val_urn, $df_doi, $val_doi, $df_othes, $val_othes, $df_utheses, $val_utheses);
+
+  foreach my $cf (@{$mrd->{controlfield}})
+  {
+    if ($cf->{tag} eq '005')
+    {
+      $rec->{ts_marc}= $cf->{content};
+    }
+  }
+
+  foreach my $df (@{$mrd->{datafield}})
+  {
+    foreach my $sf (@{$df->{subfield}})
+    {
+      if ($sf->{content} =~ m#urn:nbn#)
+      {
+        $df_urn= join(':', (map { $df->{$_} } qw(tag ind1 ind2)), $sf->{code});
+        $val_urn= $sf->{content};
+      }
+      elsif ($sf->{content} =~ m#10\.25365#)
+      {
+        $df_doi= join(':', (map { $df->{$_} } qw(tag ind1 ind2)), $sf->{code});
+        $val_doi= $sf->{content};
+      }
+      elsif ($sf->{content} =~ m#othes\.univie#)
+      {
+        $df_othes= join(':', (map { $df->{$_} } qw(tag ind1 ind2)), $sf->{code});
+        $val_othes= $sf->{content};
+      }
+      elsif ($sf->{content} =~ m#utheses\.univie#)
+      {
+        $df_utheses= join(':', (map { $df->{$_} } qw(tag ind1 ind2)), $sf->{code});
+        $val_utheses= $sf->{content};
+      }
+    }
+  }
+  $rec->{ df_urn}=      $df_urn;
+  $rec->{val_urn}=     $val_urn;
+  $rec->{ df_doi}=      $df_doi;
+  $rec->{val_doi}=     $val_doi;
+  $rec->{ df_othes}=    $df_othes;
+  $rec->{val_othes}=   $val_othes;
+  $rec->{ df_utheses}=  $df_utheses;
+  $rec->{val_utheses}= $val_utheses;
+
+  $rec;
+}
+
+1;
+