SwitchCase+Button and value simulator

Hi guys,
I think i’m in need of some help. The ojective of my code is to have a function to read the button state, and from that, generate values from the simulator, and when the button is pressed again, turn those values to 0 or off. This is what i came up with so far

#define BUTTON 7

bool buttonEvent=false; 

int vL;
int vR;

void setup(){

  pinMode(BUTTON,INPUT_PULLUP); 
  Serial.begin(115200);
  }
void loop(){ 
  autoSim();
  autoButton();
  }
void autoButton(){

  const int PIN=BUTTON;  //HW pin
  const int WAIT=0, REPLACE=1, OFF = 2; //states
  static int state=WAIT; //state variable

  static bool buttonStateBefore = !digitalRead(BUTTON);
  bool buttonState; 

  switch(state){  
    case WAIT:
      
      buttonState = !digitalRead(BUTTON);
      
      if(buttonState>buttonStateBefore){//button goes down  
        buttonStateBefore=buttonState;
        state=REPLACE;}
      else if (buttonState<buttonStateBefore){//button goes up  
        buttonStateBefore=buttonState;
        state = OFF;}
    break;
    case OFF:
      buttonEvent=false;
      if(true){
        state = WAIT;
      }
     break;
    case REPLACE:
      buttonEvent=true; 
      
      if(true){
        state=WAIT;}    
    break; }}

void autoSim(){
  
  //hardware 
  //const int PIN=;  //HW pin
  
  //state machine
  const int WAIT=0, REPLACE=1, OFF=2; //states
  static int state=WAIT; //state variable

  //time protocol
  unsigned long T0=millis(); //global timestamp
  static unsigned long t0=millis(); //local timestamp
  unsigned long t; //current time variable

  int simDC=50, simAC=30; 
  
  unsigned long T=5000; 
  int dT=T/100; 
  
  switch(state){ //state machine
    case WAIT:
      t=millis();
      if((t-t0)>(dT)){
        t0=millis();
        state=REPLACE;}
      else if(buttonEvent == false){
        state = OFF;
      }
      
    break;
    case REPLACE:
      
        
      
      vL=simDC+simAC*sin(2*PI*(t-T0)/T);
      vR=simDC-simAC*sin(2*PI*(t-T0)/T);
      Serial.print(vL);
      Serial.print('\t');
      Serial.print(vR);
      Serial.print('\t');
      Serial.print(t);
      Serial.print('\t');
      Serial.print(T0);
      Serial.print('\t');
      Serial.print(T);
      Serial.println('\t');     
      if(true){
        state=WAIT;}
    break;
    case OFF:
      vL = 0;
      vR = 0;

      if(buttonEvent==true){
        state = WAIT;
      }
     break;
    
  }}

The code works ok the beginning, which is to first click the button to start generating the values. The problem lies when i have to stop the simulator/turn the values to 0. It only works while the button is pressed continuously. Any tip?