diff --git a/pae2xml.pl b/pae2xml.pl
index c99c0aa3b5123ccf8b7c49739a2a02e8926bed11..bc79762317a913b9eb4a64c52718c5b7f7f3968c 100755
--- a/pae2xml.pl
+++ b/pae2xml.pl
@@ -318,50 +318,33 @@ sub parse_notes {
       parse_note($note, $keysig, "", "", $qq);
     } elsif ($notes =~ /^(\(({?(\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?){3}\))(.*)$/) {  # a triplet
       ($triplet, $notes) = ($1,$8);
-      #      print "TRIPLET: ".$triplet." -> ";
       $triplet =~ /^\(({?(\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)(.*)\)$/gs;
       ($note, $triplet) = ($1,$7);
-      #print "$note $triplet\n";
-      parse_note($note, $keysig, '<tuplet type="start"/>', '				<time-modification>
+      my $time_mod = "				<time-modification>
 					<actual-notes>3</actual-notes>
 					<normal-notes>2</normal-notes>
-				</time-modification>', $qq);
+				</time-modification>\n";
+      parse_note($note, $keysig, '<tuplet type="start"/>', $time_mod, $qq);
       $triplet =~ /^({?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)(.*)$/gs;
       ($note, $triplet) = ($1,$6);
-      #print "$note $triplet\n";
-      parse_note($note, $keysig,  '', '				<time-modification>
-					<actual-notes>3</actual-notes>
-					<normal-notes>2</normal-notes>
-				</time-modification>', $qq);
-      parse_note($triplet,  $keysig, '<tuplet type="stop"/>',  '				<time-modification>
-					<actual-notes>3</actual-notes>
-					<normal-notes>2</normal-notes>
-				</time-modification>', $qq);
+      parse_note($note, $keysig,  '', $time_mod, $qq);
+      parse_note($triplet,  $keysig, '<tuplet type="stop"/>',  $time_mod, $qq);
     } elsif ($notes =~ /^((\d+)\(({?(\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)+\;(\d+)\))(.*)$/)  {  # an n-tuplet
       ($tuplet, $notes) = ($1,$10);
-      #      print "N-TUPLET: ".$tuplet." -> ";
-      $tuplet =~ /^(\d+)\(({?(\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?}?)(.*);(\d)\)$/gs;
-      ($combdur, $note, $tuplet, $numval) = ($1,$2,$7,$8);
-      #print "i=$combdur, n=$numval; $note / $tuplet\n";
-      my $ind_dur = duration($combdur)/$numval;
-      # my $norm_notes =
+      $tuplet =~ /^(\d+)\(({?(\,|\')*(x|xx|b|bb|n)?(\d*\.*)(g|q)?(\-|A|B|C|D|E|F|G)t?\+?}?)(.*);(\d)\)$/gs;
+      ($combdur, $note, $notedur, $tuplet, $numval) = ($1,$2,$5, $8,$9);
       my $act_notes = $numval;
-      parse_note($note, $keysig, '<tuplet type="start"/>', '				<time-modification>
-					<actual-notes>'.$act_notes.'</actual-notes>
-					<normal-notes>1</normal-notes>
-				</time-modification>', $qq);
+      my $norm_notes = duration($combdur)/duration($notedur);
+      my $time_mod = "				<time-modification>
+					<actual-notes>$act_notes</actual-notes>
+					<normal-notes>$norm_notes</normal-notes>
+				</time-modification>\n";
+      parse_note($note, $keysig, '<tuplet type="start"/>', $time_mod, $qq);
       while ($tuplet =~ /^({?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?\}?)([^}]+}?)$/gs) {
         ($note, $tuplet) = ($1,$6);
-        #print "$note / $tuplet\n";
-        parse_note($note, $keysig,  '', '				<time-modification>
-					<actual-notes>'.$act_notes.'</actual-notes>
-					<normal-notes>1</normal-notes>
-				</time-modification>', $qq);
+        parse_note($note, $keysig,  '', $time_mod, $qq);
       }
-      parse_note($tuplet,  $keysig, '<tuplet type="stop"/>',  '				<time-modification>
-					<actual-notes>'.$act_notes.'</actual-notes>
-					<normal-notes>1</normal-notes>
-				</time-modification>', $qq);
+      parse_note($tuplet,  $keysig, '<tuplet type="stop"/>', $time_mod, $qq);
     } elsif ($notes =~ /^(%(\w(-|\+)\d))(.*)$/) {  # Clef change
       ($clef,$notes) = ($2,$4);
       print OUT "			<attributes>\n";
@@ -597,7 +580,7 @@ sub parse_note {
 ';
   }
   if ($notation ne "") {
-    print OUT "                         $notation\n";
+    print OUT "					$notation\n";
   }
   if ($notationbracket) {
     print OUT "				</notations>\n";
diff --git a/sample_files/Tuplets.pae b/sample_files/Tuplets.pae
new file mode 100644
index 0000000000000000000000000000000000000000..96fb4c1e1b055057977a8d7c832bb1dd1fac2387
--- /dev/null
+++ b/sample_files/Tuplets.pae
@@ -0,0 +1,7 @@
+Test Composer
+Test case for tuplets
+1.1.1: S tuplets
+plain&easy: %G-2@c$� '1C/4C4('6DEFGA;5)2C/8C8({'3DEFGA};5)4C2-/8-8(6ABC;3)8-8({6ABC};3)8-(6ABC)8-({6ABC})/1C//
+
+Test Library
+00000000
\ No newline at end of file