   // Update motor position
   if(update_flag) {
     // Update stepper position (Z/AZM)
-    float degreesActuallyCorrected = rotateStepperBy(positionChange);
-    positionChange -= degreesActuallyCorrected;
+    float degreesActuallyCorrected = rotateStepperBy(-positionChange);
+    positionChange += degreesActuallyCorrected;
     // Reset flag
     update_flag = false;
   }

    imu.readGyro();
    float z = imu.calcGyro(imu.gz);
    zSum += z;
    delay(10);
  }
  return zSum / calibrationSamples;

// ================ SYSTEM PARAMETERS ===================
// Sample rates
int motorUpdateRate = 50; // gyro sample rate
int calibrationSamples = 500;

// Initial calibration value
float calibratedOffset = 0;
