OSC. Trying to join working code together!

Dear all.

I am working on a hardware game where I want to count the pulses of some LED’s in order to send this data to an IPAD via OSC, This works just fine,
I also then want to send some commands back via OSC to control game modes.
This also works just fine.
The problem is I cant get the two segments to work together, Usually the send back fails.
I am aware that the PulseInLong that i am using for the count does make the code very laggey however this does not seem to be the problem.
Could anyone help me to make an efficient combined code?
I have deliberately left out everything except the loop as its very complicated.
And please no grumpy comments about the “goto” it seemed in the end to be the most efficient method to ensure no counting errors and I know some will frown at them!
Both parts of the code below.

// Code part 1 //
void loop() {

duration1 = pulseInLong(buttonPin1, HIGH);
duration2 = pulseInLong(buttonPin2, HIGH);
duration3 = pulseInLong(buttonPin3, HIGH);
duration4 = pulseInLong(buttonPin4, HIGH);

buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);

if (duration1 > 200000
|| duration2 > 200000
|| duration3 > 200000
|| duration4 > 200000 ){
Lives = 0;
goto bailout;}

if (buttonState1 == 0 && buttonState2 == 0
&& buttonState2 == 0 && buttonState2 == 0){
Lives = 12;
goto bailout;}

if (buttonState1 == 1 && buttonState2 == 0 ){
Lives = 9;}

if (buttonState2 == 1 && buttonState3 == 0 ){
Lives = 6;}

if (buttonState3 == 1 && buttonState4 == 0 ){
Lives = 3;}

if (duration4 > 102900 && duration4 < 104000){
Lives = 1;
goto bailout;}
if (duration4 > 171000 && duration4 < 172000){
Lives = 2;
goto bailout;}

if (duration3 > 102900 && duration3 < 104000){
Lives = 4;
goto bailout;}
if (duration3 > 171000 && duration3 < 172000){
Lives = 5;
goto bailout;}

if (duration2 > 102900 && duration2 < 104000){
Lives = 7;
goto bailout;}
if (duration2 > 171000 && duration2 < 172000){
Lives = 8;
goto bailout;}

if (duration1 > 102900 && duration1 < 104000){
Lives = 10;
goto bailout;}
if (duration1 > 171000 && duration1 < 172000){
Lives = 11;}

bailout:
delay (500);
Serial.print(“Lives: “);
Serial.println(Lives);
OSCMessage msg(”/1/label4”);
msg.add(Lives);
Udp.beginPacket(outIp, outPort);
msg.send(Udp);
Udp.endPacket();
msg.empty();

}

//////////////////////////////////////////

// Code part 2 //

void loop() {
OSCMsgReceive();

}

void OSCMsgReceive(){
OSCMessage msgIN;
int size;
if((size = Udp.parsePacket())>0){
while(size–)
msgIN.fill(Udp.read());
if(!msgIN.hasError()){

msgIN.route("/1/push1",toggle1);

}}}

void toggle1(OSCMessage &msg, int addrOffset){
Team = (boolean) msg.getFloat(0);
OSCMessage msgOUT("/1/push1");

if (Team == 1) {
digitalWrite(button1, Team);
Serial.print("Team: ");
Serial.println(Team);
delay (100); }
msgOUT.add( Team);}

I looked at your code. There is NO excuse for using goto in a C++ program.

When you stop doing that, by writing proper code, then your problem might go away. If not, post the goto-less code, and I’ll have a look at it again.