diff --git a/GeoLib/AnalyticalGeometry-impl.h b/GeoLib/AnalyticalGeometry-impl.h
index a1df7be610b8eafb19edfab7b4ba2e024b70229b..758faef0607d32bd561abbf4fbe478ce6b95398d 100644
--- a/GeoLib/AnalyticalGeometry-impl.h
+++ b/GeoLib/AnalyticalGeometry-impl.h
@@ -119,30 +119,25 @@ void computeRotationMatrixToXY(MathLib::Vector3 const& n,
 {
     // check if normal points already in the right direction
     if (n[0] == 0 && n[1] == 0) {
+        rot_mat(0,1) = 0.0;
+        rot_mat(0,2) = 0.0;
+        rot_mat(1,0) = 0.0;
+        rot_mat(1,1) = 1.0;
+        rot_mat(1,2) = 0.0;
+        rot_mat(2,0) = 0.0;
+        rot_mat(2,1) = 0.0;
+
         if (n[2] > 0) {
+            // identity matrix
             rot_mat(0,0) = 1.0;
-            rot_mat(0,1) = 0.0;
-            rot_mat(0,2) = 0.0;
-            rot_mat(1,0) = 0.0;
-            rot_mat(1,1) = 1.0;
-            rot_mat(1,2) = 0.0;
-            rot_mat(2,0) = 0.0;
-            rot_mat(2,1) = 0.0;
             rot_mat(2,2) = 1.0;
-            return;
         } else {
             // rotate by pi about the y-axis
             rot_mat(0,0) = -1.0;
-            rot_mat(0,1) = 0.0;
-            rot_mat(0,2) = 0.0;
-            rot_mat(1,0) = 0.0;
-            rot_mat(1,1) = 1.0;
-            rot_mat(1,2) = 0.0;
-            rot_mat(2,0) = 0.0;
-            rot_mat(2,1) = 0.0;
             rot_mat(2,2) = -1.0;
-            return;
         }
+
+        return;
     }
 
     // sqrt (n_1^2 + n_3^2)