diff --git a/src/game/game.py b/src/game/game.py
index 2e725cd..63ee8a1 100644
--- a/src/game/game.py
+++ b/src/game/game.py
@@ -101,7 +101,7 @@ def store_move_an(self, move, previous_legal_moves):
         if an == "P":
             an = ""
 
-        # Specify initial column, file or both for ambiguous moves.
+        # Specify initial file (column), rank (row) or both for ambiguous moves.
         ambiguous_moves = []
         for from_xy in previous_legal_moves:
             if (
@@ -125,7 +125,7 @@ def store_move_an(self, move, previous_legal_moves):
             else:
                 if ambiguous_x:
                     an += str(self.board.width - move.from_y)
-                if ambiguous_y:
+                else:
                     an += ascii_lowercase[move.from_x]
 
         if move.captured_piece:
@@ -163,7 +163,11 @@ def move_piece_an(self, an):
 
         piece_name = matches.group(1) or "P"
         from_x = matches.group(2)
+        if from_x:
+            from_x = ascii_lowercase.index(from_x)
         from_y = matches.group(3)
+        if from_y:
+            from_y = self.board.width - int(from_y)
 
         for from_xy in self.legal_moves:
             if self.board.get_piece(from_xy[0], from_xy[1]).name.upper() == piece_name:
diff --git a/src/tests/game/game_test.py b/src/tests/game/game_test.py
index 913dc99..e2b1ed5 100644
--- a/src/tests/game/game_test.py
+++ b/src/tests/game/game_test.py
@@ -28,6 +28,11 @@ def test_store_move_an_kings_pawn(self):
         self.game.store_move_an(move, self.game.legal_moves)
         self.assertEqual(self.game.an_moves[-1], "e3")
 
+    def test_store_move_an_ambiguous_move(self):
+        for an in ["a4", "a5", "h4", "h5", "Ra3", "Ra6", "Rhh3"]:
+            self.game.move_piece_an(an)
+        self.assertEqual(self.game.an_moves[-1], "Rhh3")
+
     def test_move_piece_an_kings_pawn(self):
         self.assertIsNone(self.game.board.get_piece(4, 5))
         self.game.move_piece_an("e3")