Code does IF statement even when IF statement isnt true?

Perhaps the very good approach is to change to a state machine.

If you want to solve it on an ad hocery, you can also use interrupts to set the abort-flag.

Very true! That's exactly what's happening. I will try a *state machine. Thank you!

If you want to change the by using the button whit a press (acting like a switch)

add to the globe vars ( the top of your program, just onder your const / #define). se wen can remember what heppend in the previos loop:

bool prevButtonPress = false; //change it to default state of the butotn
bool state           = true;  //start whit on shwitch

add to the mainloop:

this will only be true when u press the button, and the previons time u did not press it.so if you if you loop run this code a seccond time but you still hold the button wil this prevButtonPress != button not be true and skip chaching the state

if (button == true && prevButtonPress != button ){
   state == !state;  // invert the value of state
}

update prevButtonPress so the next loop knows the state of the button

prevButtonPress  = button ;

Now we can make a if stament to run code depending on the sate:

if (state == true){
//code if state

}else{
//code if not state
}