diff --git a/rigify/rigs/biped/arm/deform.py b/rigify/rigs/biped/arm/deform.py
index 0e671359106581519c48d7fe5aab08a51917de98..265c944de257efa1387853d3520f510825d81b85 100644
--- a/rigify/rigs/biped/arm/deform.py
+++ b/rigify/rigs/biped/arm/deform.py
@@ -48,7 +48,7 @@ def align_roll(obj, bone1, bone2):
     rot_mat = Matrix.Rotation(angle, 3, axis)
 
     # Roll factor
-    x3 = x1 * rot_mat
+    x3 = rot_mat * x1
     dot = x2 * x3
     if dot > 1.0:
         dot = 1.0
@@ -60,7 +60,7 @@ def align_roll(obj, bone1, bone2):
     bone1_e.roll = roll
 
     # Check if we rolled in the right direction
-    x3 = bone1_e.x_axis * rot_mat
+    x3 = rot_mat * bone1_e.x_axis
     check = x2 * x3
 
     # If not, reverse
diff --git a/rigify/rigs/biped/leg/deform.py b/rigify/rigs/biped/leg/deform.py
index d0f98e4a33f939357c9f6d8dedce211783e6f832..3a64913943cf2fe190c1df1d689791348046e656 100644
--- a/rigify/rigs/biped/leg/deform.py
+++ b/rigify/rigs/biped/leg/deform.py
@@ -48,7 +48,7 @@ def align_roll(obj, bone1, bone2):
     rot_mat = Matrix.Rotation(angle, 3, axis)
 
     # Roll factor
-    x3 = x1 * rot_mat
+    x3 = rot_mat * x1
     dot = x2 * x3
     if dot > 1.0:
         dot = 1.0
@@ -60,7 +60,7 @@ def align_roll(obj, bone1, bone2):
     bone1_e.roll = roll
 
     # Check if we rolled in the right direction
-    x3 = bone1_e.x_axis * rot_mat
+    x3 = rot_mat * bone1_e.x_axis
     check = x2 * x3
 
     # If not, reverse