diff --git a/META.json b/META.json
index 7238eed..c3de776 100644
--- a/META.json
+++ b/META.json
@@ -4,13 +4,13 @@
       "Nick Logan <ugexe@cpan.org>"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921",
+   "generated_by" : "ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010",
    "license" : [
       "perl_5"
    ],
    "meta-spec" : {
       "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
-      "version" : "2"
+      "version" : 2
    },
    "name" : "Text-Levenshtein-Damerau",
    "no_index" : {
@@ -56,5 +56,6 @@
          "url" : "https://github.com/ugexe/Text--Levenshtein--Damerau"
       }
    },
-   "version" : "0.41"
+   "version" : "0.42",
+   "x_serialization_backend" : "JSON::PP version 4.06"
 }
diff --git a/META.yml b/META.yml
index e9896bd..bd54c37 100644
--- a/META.yml
+++ b/META.yml
@@ -3,15 +3,15 @@ abstract: 'Damerau Levenshtein edit distance.'
 author:
   - 'Nick Logan <ugexe@cpan.org>'
 build_requires:
-  Test::More: 0
+  Test::More: '0'
 configure_requires:
-  ExtUtils::MakeMaker: 0
+  ExtUtils::MakeMaker: '0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921'
+generated_by: 'ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
+  version: '1.4'
 name: Text-Levenshtein-Damerau
 no_index:
   directory:
@@ -20,14 +20,15 @@ no_index:
 provides:
   Text::Levenshtein::Damerau:
     file: lib/Text/Levenshtein/Damerau.pm
-    version: 0.41
+    version: '0.41'
   Text::Levenshtein::Damerau::PP:
     file: lib/Text/Levenshtein/Damerau/PP.pm
-    version: 0.25
+    version: '0.25'
 requires:
-  List::Util: 0
-  perl: 5.008008
+  List::Util: '0'
+  perl: '5.008008'
 resources:
   bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Levenshtein-Damerau
   repository: https://github.com/ugexe/Text--Levenshtein--Damerau
-version: 0.41
+version: '0.42'
+x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff --git a/README b/README
deleted file mode 100644
index c6c6e9d..0000000
--- a/README
+++ /dev/null
@@ -1,170 +0,0 @@
-NAME
-    Text::Levenshtein::Damerau - Damerau Levenshtein edit distance.
-
-SYNOPSIS
-            use Text::Levenshtein::Damerau;
-
-            my @targets = ('fuor','xr','fourrrr','fo');
-
-            # Initialize Text::Levenshtein::Damerau object with text to compare against
-            my $tld = Text::Levenshtein::Damerau->new('four');
-
-            print $tld->dld($targets[0]);
-            # prints 1
-
-            my $tld = $tld->dld({ list => \@targets });
-            print $tld->{'fuor'};
-            # prints 1
-
-            print $tld->dld_best_match({ list => \@targets });
-            # prints fuor
-
-            print $tld->dld_best_distance({ list => \@targets });
-            # prints 1
-
-
-            # or even more simply
-            use Text::Levenshtein::Damerau qw/edistance/;
-        
-            print edistance('Neil','Niel');
-            # prints 1
-
-DESCRIPTION
-    Returns the true Damerau Levenshtein edit distance of strings with
-    adjacent transpositions. Useful for fuzzy matching, DNA variation
-    metrics, and fraud detection.
-
-    Defaults to using Pure Perl Text::Levenshtein::Damerau::PP, but has an
-    XS addon Text::Levenshtein::Damerau::XS for massive speed imrovements.
-    Works correctly with utf8 if backend supports it; known to work with
-    "Text::Levenshtein::Damerau::PP" and "Text::Levenshtein::Damerau::XS".
-
-            use Text::Levenshtein::Damerau;
-            use utf8;
-
-            my $tld = Text::Levenshtein::Damerau->new('ⓕⓞⓤⓡ');
-            print $tld->dld('ⓕⓤⓞⓡ');
-            # prints 1
-
-CONSTRUCTOR
-  new
-    Creates and returns a "Text::Levenshtein::Damerau" object. Takes a
-    scalar with the text (source) you want to compare against.
-
-            my $tld = Text::Levenshtein::Damerau->new('Neil');
-            # Creates a new Text::Levenshtein::Damerau object $tld
-
-METHODS
-  $tld->dld
-    Scalar Argument: Takes a string to compare with.
-
-    Returns: an integer representing the edit distance between the source
-    and the passed argument.
-
-    Hashref Argument: Takes a hashref containing:
-
-    *   list => \@array (array ref of strings to compare with)
-
-    *   *OPTIONAL* max_distance => $int (only return results with $int
-        distance or less).
-
-    *   *OPTIONAL* backend => 'Some::Module::its_function' Any module that
-        will take 2 arguments and returns an int. If the module fails to
-        load, the function doesn't exist, or the function doesn't return a
-        number when passed 2 strings, then "backend" remains unchanged.
-
-                # Override defaults and use Text::Levenshtein::Damerau::PP's pp_edistance()
-                $tld->dld({ list=> \@list, backend => 'Text::Levenshtein::Damerau::PP::pp_edistance');
-
-                # Override defaults and use Text::Levenshtein::Damerau::XS's xs_edistance()
-                use Text::Levenshtein::Damerau;
-                requires Text::Levenshtein::Damerau::XS;
-                ...
-                $tld->dld({ list=> \@list, backend => 'Text::Levenshtein::Damerau::XS::xs_edistance');
-
-    Returns: hashref with each word from the passed list as keys, and their
-    edit distance (if less than max_distance, which is unlimited by
-    default).
-
-            my $tld = Text::Levenshtein::Damerau->new('Neil');
-            print $tld->dld( 'Niel' );
-            # prints 1
-
-            #or if you want to check the distance of various items in a list
-
-            my @names_list = ('Niel','Jack');
-            my $tld = Text::Levenshtein::Damerau->new('Neil');
-            my $d_ref = $tld->dld({ list=> \@names_list }); # pass a list, returns a hash ref
-            print $d_ref->{'Niel'}; #prints 1
-            print $d_ref->{'Jack'}; #prints 4
-
-  $tld->dld_best_match
-    Argument: an array reference of strings.
-
-    Returns: the string with the smallest edit distance between the source
-    and the array of strings passed.
-
-    Takes distance of $tld source against every item in @targets, then
-    returns the string of the best match.
-
-            my $tld = Text::Levenshtein::Damerau->new('Neil');
-            my @name_spellings = ('Niel','Neell','KNiel');
-            print $tld->dld_best_match({ list=> \@name_spellings });
-            # prints Niel
-
-  $tld->dld_best_distance
-    Arguments: an array reference of strings.
-
-    Returns: the smallest edit distance between the source and the array
-    reference of strings passed.
-
-    Takes distance of $tld source against every item in the passed array,
-    then returns the smallest edit distance.
-
-            my $tld = Text::Levenshtein::Damerau->new('Neil');
-            my @name_spellings = ('Niel','Neell','KNiel');
-            print $tld->dld_best_distance({ list => \@name_spellings });
-            # prints 1
-
-EXPORTABLE METHODS
-  edistance
-    Arguments: source string and target string.
-
-    *   *OPTIONAL 3rd argument* int (max distance; only return results with
-        $int distance or less). 0 = unlimited. Default = 0.
-
-    Returns: int that represents the edit distance between the two argument.
-    -1 if max distance is set and reached.
-
-    Wrapper function to take the edit distance between a source and target
-    string. It will attempt to use, in order:
-
-    *   Text::Levenshtein::Damerau::XS xs_edistance
-
-    *   Text::Levenshtein::Damerau::PP pp_edistance
-
-            use Text::Levenshtein::Damerau qw/edistance/;
-            print edistance('Neil','Niel');
-            # prints 1
-
-SEE ALSO
-    *   <https://github.com/ugexe/Text--Levenshtein--Damerau> *repository*
-
-    *   <http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance>
-        *damerau levenshtein explaination*
-
-    *   Text::Fuzzy *regular levenshtein distance*
-
-BUGS
-    Please report bugs to:
-
-    <https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Levenshtein-Dame
-    rau>
-
-AUTHOR
-    Nick Logan <ug@skunkds.com>
-
-LICENSE AND COPYRIGHT
-    This library is free software; you can redistribute it and/or modify it
-    under the same terms as Perl itself.
-
diff --git a/debian/changelog b/debian/changelog
index ada6d96..a0e08a5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-libtext-levenshtein-damerau-perl (0.41-2) UNRELEASED; urgency=medium
+libtext-levenshtein-damerau-perl (0.41+git20190322.1.240cebb-1) UNRELEASED; urgency=medium
 
   [ Salvatore Bonaccorso ]
   * debian/control: Use HTTPS transport protocol for Vcs-Git URI
@@ -12,7 +12,10 @@ libtext-levenshtein-damerau-perl (0.41-2) UNRELEASED; urgency=medium
   [ gregor herrmann ]
   * debian/watch: use uscan version 4.
 
- -- Salvatore Bonaccorso <carnil@debian.org>  Sat, 30 Jan 2016 20:07:02 +0100
+  [ Debian Janitor ]
+  * New upstream snapshot.
+
+ -- Salvatore Bonaccorso <carnil@debian.org>  Sun, 20 Mar 2022 09:00:53 -0000
 
 libtext-levenshtein-damerau-perl (0.41-1.1) unstable; urgency=medium
 
diff --git a/lib/Text/Levenshtein/Damerau.pm b/lib/Text/Levenshtein/Damerau.pm
index 99d54a5..832e644 100644
--- a/lib/Text/Levenshtein/Damerau.pm
+++ b/lib/Text/Levenshtein/Damerau.pm
@@ -7,7 +7,7 @@ require Exporter;
 
 our @ISA = qw(Exporter); 
 our @EXPORT_OK = qw/edistance/;
-our $VERSION   = '0.41';
+our $VERSION   = '0.42';
  
 # To XS or not to XS...
 unless ( _set_backend('Text::Levenshtein::Damerau::XS::xs_edistance') ) {
@@ -137,7 +137,7 @@ Text::Levenshtein::Damerau - Damerau Levenshtein edit distance.
 
 Returns the true Damerau Levenshtein edit distance of strings with adjacent transpositions. Useful for fuzzy matching, DNA variation metrics, and fraud detection.
 
-Defaults to using Pure Perl L<Text::Levenshtein::Damerau::PP>, but has an XS addon L<Text::Levenshtein::Damerau::XS> for massive speed imrovements. Works correctly with utf8 if backend supports it; known to work with C<Text::Levenshtein::Damerau::PP> and C<Text::Levenshtein::Damerau::XS>.
+Defaults to using Pure Perl L<Text::Levenshtein::Damerau::PP>, but has an XS addon L<Text::Levenshtein::Damerau::XS> for massive speed improvements. Works correctly with utf8 if backend supports it; known to work with C<Text::Levenshtein::Damerau::PP> and C<Text::Levenshtein::Damerau::XS>.
 
 	use utf8;
 	my $tld = Text::Levenshtein::Damerau->new('ⓕⓞⓤⓡ');
@@ -256,21 +256,21 @@ Wrapper function to take the edit distance between a source and target string. I
 
 =item * L<https://github.com/ugexe/Text--Levenshtein--Damerau> I<Repository>
 
-=item * L<http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance> I<Damerau levenshtein explanation>
-
 =item * L<Text::Fuzzy> I<Regular levenshtein distance>
 
+=item * L<Text::Levenshtein::XS> I<Regular levenshtein distance>
+
 =back
 
 =head1 BUGS
 
 Please report bugs to:
 
-L<https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Levenshtein-Damerau>
+L<https://github.com/ugexe/Text--Levenshtein--Damerau/issues>
 
 =head1 AUTHOR
 
-Nick Logan <F<ug@skunkds.com>>
+Nick Logan <F<ugexe@cpan.org>>
 
 =head1 LICENSE AND COPYRIGHT
 
diff --git a/lib/Text/Levenshtein/Damerau/PP.pm b/lib/Text/Levenshtein/Damerau/PP.pm
index d908f31..b557a6b 100644
--- a/lib/Text/Levenshtein/Damerau/PP.pm
+++ b/lib/Text/Levenshtein/Damerau/PP.pm
@@ -1,87 +1,71 @@
 package Text::Levenshtein::Damerau::PP;
 use 5.008_008;    # for utf8, sorry legacy Perls
 use strict;
-use List::Util qw/min/;
+use List::Util qw/min max/;
 require Exporter;
  
 our @ISA = qw(Exporter);
 our @EXPORT_OK = qw/pp_edistance/;
-our $VERSION   = '0.25';
+our $VERSION   = '0.26';
+
 
 sub pp_edistance {
-    # Does the actual calculation on a pair of strings
-    my ( $source, $target, $max_distance ) = @_;
-    $max_distance = int($max_distance || 0);
-
-    my $source_length = length($source) || 0;
-    my $target_length = length($target) || 0;
-    return ($source_length?$source_length:$target_length) if(!$target_length || !$source_length);
-
-    my $lengths_max = $source_length + $target_length;
-    my $dictionary_count;    #create dictionary to keep character count
-    my $swap_count;          
-    my $swap_score;          
-    my $target_char_count;   
-    my $source_index;
-    my $target_index;
-    my @scores;              
-
-    # init values outside of work loops
-    $scores[0][0] = $scores[1][0] = $scores[0][1] = $lengths_max;
-    $scores[1][1] = 0;
-
-    # Work Loops
-    foreach $source_index ( 1 .. $source_length ) {
-        $swap_count = 0;
-        $dictionary_count->{ substr( $source, $source_index - 1, 1 ) } = 0;
-        $scores[ $source_index + 1 ][1] = $source_index;
-        $scores[ $source_index + 1 ][0] = $lengths_max;
-
-        foreach $target_index ( 1 .. $target_length ) {
-            if ( $source_index == 1 ) {
-                $dictionary_count->{ substr( $target, $target_index - 1, 1 ) } = 0;
-                $scores[1][ $target_index + 1 ] = $target_index;
-                $scores[0][ $target_index + 1 ] = $lengths_max;
-            }
-
-            $target_char_count =
-              $dictionary_count->{ substr( $target, $target_index - 1, 1 ) };
-	     $swap_score = $scores[$target_char_count][$swap_count] +
-                  ( $source_index - $target_char_count - 1 ) + 1 +
-                  ( $target_index - $swap_count - 1 );
-
-            if (
-                substr( $source, $source_index - 1, 1 ) ne
-                substr( $target, $target_index - 1, 1 ) )
-            {
-                $scores[ $source_index + 1 ][ $target_index + 1 ] = min(
-                    $scores[$source_index][$target_index]+1,
-                    $scores[ $source_index + 1 ][$target_index]+1,
-                    $scores[$source_index][ $target_index + 1 ]+1,
-                    $swap_score
-                );
-            }
-            else {
-                $swap_count = $target_index;
+    my ( $source, $target, $max ) = @_;
+    my $maxd = (defined $max && $max >= 0) ? $max : max(length($source), length($target));
+
+    my $sourceLength = length($source) || 0;
+    my $targetLength = length($target) || 0;
+    my (@currentRow, @previousRow, @transpositionRow);
+
+    # Swap source/target so that $sourceLength always contains the shorter string
+    if ($sourceLength > $targetLength) {
+        ($source,$target)             = ($target,$source);
+        ($sourceLength,$targetLength) = ($targetLength,$sourceLength);
+    }
 
-                $scores[ $source_index + 1 ][ $target_index + 1 ] = min(
-                  $scores[$source_index][$target_index], $swap_score
+    return ((!defined $max || $maxd <= $targetLength)
+        ? $targetLength : -1) if($sourceLength == 0 || $targetLength == 0);
+
+    my $diff = $targetLength - $sourceLength;
+    return -1 if defined $max && $diff > $maxd;
+    
+    $previousRow[$_] = $_ for 0..$sourceLength+1;
+
+    my $lastTargetCh = '';
+    foreach my $i  (1..$targetLength) {
+        my $targetCh   = substr($target, $i - 1, 1);
+        $currentRow[0] = $i;
+        my $start      = max($i - $maxd - 1, 1);
+        my $end        = min($i + $maxd + 1, $sourceLength);
+
+        my $lastSourceCh = '';
+        foreach my $j ($start..$end) {
+            my $sourceCh = substr($source, $j - 1, 1);
+            my $cost     = $sourceCh eq $targetCh ? 0 : 1;
+
+            $currentRow[$j] = min(
+                $currentRow[$j - 1] + 1, 
+                $previousRow[$j >= scalar @previousRow ? -1 : $j] + 1,
+                $previousRow[$j - 1] + $cost,
+                    ($sourceCh eq $lastTargetCh && $targetCh eq $lastSourceCh)
+                        ? $transpositionRow[$j - 2] + $cost
+                        : $maxd + 1
                 );
-            }
+
+            $lastSourceCh = $sourceCh;
         }
 
-        #unless ( $max_distance == 0 || $max_distance >= $scores[ $source_index + 1 ][ $target_length + 1 ] )
-        #{
-        #    return -1;
-        #}
+        $lastTargetCh = $targetCh;
 
-        $dictionary_count->{ substr( $source, $source_index - 1, 1 ) } =
-          $source_index;
+        my @tempRow       = @transpositionRow;
+        @transpositionRow = @previousRow;
+        @previousRow      = @currentRow;
+        @currentRow       = @tempRow;
     }
- 
-    my $score = $scores[$source_length+1][$target_length+1];
-    return ($max_distance != 0 && $max_distance < $score)?(-1):$score;
+
+    return (!$max.defined || $previousRow[$sourceLength] <= $maxd) ? $previousRow[$sourceLength] : -1;
 }
+
  
 1;
 
diff --git a/t/02_pp_edistance.t b/t/02_pp_edistance.t
index 03d89be..53da0f8 100644
--- a/t/02_pp_edistance.t
+++ b/t/02_pp_edistance.t
@@ -1,39 +1,46 @@
 use strict;
 use warnings;
 
-use Test::More tests => 23;
+use Test::More tests => 26;
 use Text::Levenshtein::Damerau::PP qw/pp_edistance/;
 
-# We test pp_edistance before edistance because edistance might be using ::XS backend and fail
+{
+    # We test pp_edistance before edistance because edistance might be using ::XS backend and fail
 
-is( pp_edistance('four','four'),   0, 'test pp_edistance matching');
-is( pp_edistance('four','for'),    1, 'test pp_edistance insertion');
-is( pp_edistance('four','fourth'), 2, 'test pp_edistance deletion');
-is( pp_edistance('four','fuor'),   1, 'test pp_edistance transposition');
-is( pp_edistance('four','fxxr'),   2, 'test pp_edistance substitution');
-is( pp_edistance('four','FOuR'),   3, 'test pp_edistance case');
-is( pp_edistance('four',''), 	   4, 'test pp_edistance target empty');
-is( pp_edistance('','four'), 	   4, 'test pp_edistance source empty');
-is( pp_edistance('',''), 		   0, 'test pp_edistance source & target empty');
-is( pp_edistance('11','1'), 	   1, 'test pp_edistance numbers');
-is( pp_edistance('xxx','x',1),    -1, 'test pp_edistance > max distance setting');
-is( pp_edistance('xxx','xx',1),    1, 'test pp_edistance <= max distance setting');
+    is( pp_edistance('four','four'),   0, 'test pp_edistance matching');
+    is( pp_edistance('four','for'),    1, 'test pp_edistance insertion');
+    is( pp_edistance('four','fourth'), 2, 'test pp_edistance deletion');
+    is( pp_edistance('four','fuor'),   1, 'test pp_edistance transposition');
+    is( pp_edistance('four','fxxr'),   2, 'test pp_edistance substitution');
+    is( pp_edistance('four','FOuR'),   3, 'test pp_edistance case');
+    is( pp_edistance('four',''), 	   4, 'test pp_edistance target empty');
+    is( pp_edistance('','four'), 	   4, 'test pp_edistance source empty');
+    is( pp_edistance('',''), 		   0, 'test pp_edistance source & target empty');
+    is( pp_edistance('11','1'), 	   1, 'test pp_edistance numbers');
+    is( pp_edistance('xxx','x',1),    -1, 'test pp_edistance > max distance setting');
+    is( pp_edistance('xxx','xx',1),    1, 'test pp_edistance <= max distance setting');
 
-# some extra maxDistance tests
-is( pp_edistance("xxx","xxxx",1),   1,  'test xs_edistance misc 1');
-is( pp_edistance("xxx","xxxx",2),   1,  'test xs_edistance misc 2');
-is( pp_edistance("xxx","xxxx",3),   1,  'test xs_edistance misc 3');
-is( pp_edistance("xxxx","xxx",1),   1,  'test xs_edistance misc 4');
-is( pp_edistance("xxxx","xxx",2),   1,  'test xs_edistance misc 5');
-is( pp_edistance("xxxx","xxx",3),   1,  'test xs_edistance misc 6');
+    # some extra maxDistance tests
+    is( pp_edistance("xxx","xxxx",1),   1,  'test xs_edistance misc 1');
+    is( pp_edistance("xxx","xxxx",2),   1,  'test xs_edistance misc 2');
+    is( pp_edistance("xxx","xxxx",3),   1,  'test xs_edistance misc 3');
+    is( pp_edistance("xxxx","xxx",1),   1,  'test xs_edistance misc 4');
+    is( pp_edistance("xxxx","xxx",2),   1,  'test xs_edistance misc 5');
+    is( pp_edistance("xxxx","xxx",3),   1,  'test xs_edistance misc 6');
 
+    # test larger strings directly with edistance
+    is( pp_edistance('four' x 100, 'fuor' x 100),      100,  'dld lengths of 400');
+    is( pp_edistance('four' x 100, 'fuor' x 100, 99),   -1,  'dld lengths of 400 exceeding max value');
+    is( pp_edistance('four' x 100, 'fuor' x 100, 101), 100,  'dld lengths of 400 under max value');
+}
 
-# Test some utf8
-use utf8;
-no warnings; # Work around for Perl 5.6 and setting output encoding
-is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓞⓤⓡ'), 	0, 'test pp_edistance matching (utf8)');
-is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓞⓡ'), 	1, 'test pp_edistance insertion (utf8)');
-is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓞⓤⓡⓣⓗ'), 2, 'test pp_edistance deletion (utf8)');
-is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓤⓞⓡ'), 	1, 'test pp_edistance transposition (utf8)');
-is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓧⓧⓡ'), 	2, 'test pp_edistance substitution (utf8)');
-
+{
+    # Test some utf8
+    use utf8;
+    no warnings; # Work around for Perl 5.6 and setting output encoding
+    is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓞⓤⓡ'), 	0, 'test pp_edistance matching (utf8)');
+    is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓞⓡ'), 	1, 'test pp_edistance insertion (utf8)');
+    is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓞⓤⓡⓣⓗ'),  2, 'test pp_edistance deletion (utf8)');
+    is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓤⓞⓡ'), 	1, 'test pp_edistance transposition (utf8)');
+    is( pp_edistance('ⓕⓞⓤⓡ','ⓕⓧⓧⓡ'), 	2, 'test pp_edistance substitution (utf8)');
+}
diff --git a/t/03_dld.t b/t/03_dld.t
index 00fe5f6..c5c524d 100644
--- a/t/03_dld.t
+++ b/t/03_dld.t
@@ -4,36 +4,38 @@ use warnings;
 use Test::More tests => 14;
 use Text::Levenshtein::Damerau;
 
-my $tld = Text::Levenshtein::Damerau->new('four');
-
-#Test scalar argument
-is( $tld->dld('four'), 0, 'test helper matching');
-is( $tld->dld('for'), 1, 'test helper insertion');
-is( $tld->dld('fourth'), 2, 'test helper deletion');
-is( $tld->dld('fuor'), 1, 'test helper transposition');
-is( $tld->dld('fxxr'), 2, 'test helper substitution');
-is( $tld->dld('FOuR'), 3, 'test helper case');
-is( $tld->dld(''), 4, 'test helper empty');
-
-#Test array reference argument
-my @list = ('four','fourty','fourteen','');
-is_deeply($tld->dld({ list => \@list }), { four => 0, fourty => 2, fourteen => 4, '', => 4 }, 'test dld(\@array_ref)');
-
-
-#Test some utf8
-use utf8;
-no warnings; # Work around for Perl 5.6 and setting output encoding
-my $tld_utf8 = Text::Levenshtein::Damerau->new('ⓕⓞⓤⓡ');
-
-#Test utf8 scalar argument
-is( $tld_utf8->dld('ⓕⓞⓤⓡ'), 0, 'test helper matching (utf8)');
-is( $tld_utf8->dld('ⓕⓞⓡ'), 1, 'test helper insertion (utf8)');
-is( $tld_utf8->dld('ⓕⓞⓤⓡⓣⓗ'), 2, 'test helper deletion (utf8)');
-is( $tld_utf8->dld('ⓕⓤⓞⓡ'), 1, 'test helper transposition (utf8)');
-is( $tld_utf8->dld('ⓕⓧⓧⓡ'), 2, 'test helper substitution (utf8)');
-
-#Test utf8 array reference argument
-my @list_utf8 = ('ⓕⓞⓤⓡ','ⓕⓞⓡ','ⓕⓤⓞⓡ','');
-is_deeply($tld_utf8->dld({ list => \@list_utf8 }), { 'ⓕⓞⓤⓡ' => 0, 'ⓕⓞⓡ' => 1, 'ⓕⓤⓞⓡ' => 1, '' => 4 }, 'test dld(\@array_ref) (utf8)');
-
-
+{
+    my $tld = Text::Levenshtein::Damerau->new('four');
+
+    #Test scalar argument
+    is( $tld->dld('four'), 0, 'test helper matching');
+    is( $tld->dld('for'), 1, 'test helper insertion');
+    is( $tld->dld('fourth'), 2, 'test helper deletion');
+    is( $tld->dld('fuor'), 1, 'test helper transposition');
+    is( $tld->dld('fxxr'), 2, 'test helper substitution');
+    is( $tld->dld('FOuR'), 3, 'test helper case');
+    is( $tld->dld(''), 4, 'test helper empty');
+
+    #Test array reference argument
+    my @list = ('four','fourty','fourteen','');
+    is_deeply($tld->dld({ list => \@list }), { four => 0, fourty => 2, fourteen => 4, '', => 4 }, 
+        'test dld(\@array_ref)');
+}
+
+{
+    #Test some utf8
+    use utf8;
+    no warnings; # Work around for Perl 5.6 and setting output encoding
+    my $tld_utf8 = Text::Levenshtein::Damerau->new('ⓕⓞⓤⓡ');
+
+    #Test utf8 scalar argument
+    is( $tld_utf8->dld('ⓕⓞⓤⓡ'), 0, 'test helper matching (utf8)');
+    is( $tld_utf8->dld('ⓕⓞⓡ'), 1, 'test helper insertion (utf8)');
+    is( $tld_utf8->dld('ⓕⓞⓤⓡⓣⓗ'), 2, 'test helper deletion (utf8)');
+    is( $tld_utf8->dld('ⓕⓤⓞⓡ'), 1, 'test helper transposition (utf8)');
+    is( $tld_utf8->dld('ⓕⓧⓧⓡ'), 2, 'test helper substitution (utf8)');
+
+    #Test utf8 array reference argument
+    my @list_utf8 = ('ⓕⓞⓤⓡ','ⓕⓞⓡ','ⓕⓤⓞⓡ','');
+    is_deeply($tld_utf8->dld({ list => \@list_utf8 }), { 'ⓕⓞⓤⓡ' => 0, 'ⓕⓞⓡ' => 1, 'ⓕⓤⓞⓡ' => 1, '' => 4 }, 'test dld(\@array_ref) (utf8)');
+}