Serial communication does not work correctly between Arduino and Processing

Hello, i have a problem with communication between processing and arduino.
I can control five servos from processing and this works always correctly (in the
arduino code case 1 to case 5).
The intention is that I can put them on (attachServos()) and off (detachServos()) from
processing (in the arduino code case 6 and case 7).
The processing code sent everything correctly but the Arduino does not always
respond correctly when I want to turn off (detach) the servos.
Turning on (attach) the servos is never a problem.
Can anyone find a mistake in my programming code?
Thanks.

A part of the arduino code:

void loop(){
if (Serial.available() > 3){
startbyte = Serial.read();
if (startbyte == 255){
for (t = 0; t<2; t++){
serialInput[t] = Serial.read();
}
servo = serialInput[0];
pos = serialInput[1];
if (pos == 255){
servo = 255;
}
switch(servo){
case 1:
servo_1.write(pos);
break;
case 2:
servo_2.write(pos);
break;
case 3:
servo_3.write(pos);
break;
case 4:
servo_rotatie.write(pos);
break;
case 5:
servo_hand.write(pos);
break;
case 6:
if (pos == 180){
attachServos();
}
break;
case 7:
if (pos == 1){
detachServos();
}
break;
}
}
}
}

void attachServos(){
servo_1.attach(Servo_1_Pin, minPulse, maxPulse);
servo_2.attach(Servo_2_Pin, minPulse, maxPulse);
servo_3.attach(Servo_3_Pin, minPulse, maxPulse);

servo_rotatie.attach(Servo_4_Pin, minPulse, maxPulse);
servo_hand.attach(Servo_5_Pin, minPulse, maxPulse);
}

void detachServos(){
servo_1.detach();
servo_2.detach();
servo_3.detach();

servo_rotatie.detach();
servo_hand.detach();
}

A part of the processing code:

void ON_OFF(boolean btnEnabled) {
if ( btnEnabled==true ) {
sendMove(6, 180);
servosEnabled = true;
println("Servos enabled");
}
else {
sendMove(7, 1);
servosEnabled = false;
println("Servos not enabled");
}
}

void sendMove(int servo, int val) {
myPort.write(255);
myPort.write(servo);
myPort.write(val);
}

A part of the arduino code

So, you were looking for a part of an answer? Somehow, I don't think so.

Hello PaulS,
Maybe I expressed myself wrong. I expect no solution. I just do not understand
what is wrong in my code. Maybe jou can point me in the right direction?
Thanks.

I think the point being made was "post all of your code"

Your sketch will only call detachServos() if pos equals one. I see no way to guess what value it has when you're running your test, but if it wasn't one then that would explain your symptoms. It would be a lot easy to understand what was going on if your sketch printed status messages back to the serial port and you enhanced the Processing application to read and display them somewhere.

click the MODIFY button in the upper right of the post window.
Highlight all you code.
click the "#" CODE TAGS button on the toolbar above just to the left of the QUOTE button.
click SAVE (at the bottom).
When you post code on the forum, please make a habit of using the code tags "#" button.