       } else {
         sendJsonString("error", servoError);
       }
-    }
-  } else {
-    sendJsonString("error", servoInputError);
-  }
-}
+    } else {
+      sendJsonString("error", servoInputError);
+    }
+  }
+}


//Processes receiver input for a given servo and writes the converted output to the servo
void processServoInput(ServoData& servoData, uint16_t servoInputValue, const char servoType[], const char servoError[], const char servoInputError[]) {
  //Only use receiver values within the set range for receiver input
  if (isValidReceiverInput(servoInputValue)) {
    if (calibrationMode) {
      if (servoInputValue > servoData.inputMax) servoData.inputMax = servoInputValue;
      if (servoInputValue < servoData.inputMin) servoData.inputMin = servoInputValue;
    //Only write to servo if the receiver input for this servo has permission to do so
    } else if (receiverControl || (sharedControl && servoData.receiverInputOnly)) {
      if (servoData.servo.attached()) {
        //Constrain the servo input value to be within the calibration range (since mapping won't constrain it)
        servoInputValue = constrain(servoInputValue, servoData.inputMin, servoData.inputMax);

    //While interrupts are paused, copy new servo input values to the corresponding local static variables
    receiverInputFlagsLocal = receiverInputFlags;
    if (receiverInputFlagsLocal & FLAG_CUTOVER) cutoverInValueLocal = cutoverInValue;
    if (receiverInputFlagsLocal & FLAG_AILERON) aileronInValueLocal = aileronInValue;
    if (receiverInputFlagsLocal & FLAG_ELEVATOR) elevatorInValueLocal = elevatorInValue;
    if (receiverInputFlagsLocal & FLAG_RUDDER) rudderInValueLocal = rudderInValue;
    if (receiverInputFlagsLocal & FLAG_THROTTLE) throttleInValueLocal = throttleInValue;
    receiverInputFlags = 0;
    interrupts();
  }
