TFT Slider function issue

hello everyone
i wrote two function that controlling a slider

  1. for drawing the slider
  2. update the slider

the slider need to update a global varible and it working greate!
(after David_Prentice help me with other issues i learned the basic of how to create those functions.. )

my problem is that i have a bug that i cant find....

when i press setting button -> change the slider -> press back(to save)
and again press the setting button
sometimes the value wont change( even thoue the slider moved) its like he missed the saving part..
it happend once at 10 changes
(and it happens more when i added more code )

what am i missing ???

#include <UTFT.h>
#include <URTouch.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t Dingbats1_XL[];

enum ScreenState { HOME,DIAGNOSTIC,SETTING,NALL,SHOW_ERROR,WARNING };
ScreenState screenState = HOME;
ScreenState LastScreenstate = NALL;

UTFT          myGLCD(ILI9341_16,38,39,40,41);
//UTFT          myGLCD(ILI9486, 38, 39, 40, 41);
//UTFT          myGLCD(SSD1289, 38, 39, 40, 41);
URTouch        myTouch(6, 5, 4, 3, 2);


#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define GREY 0xEEEF

int x, y;

int TimeChangeSlider ; 
unsigned long washingTime    = 15000UL; // the global varible need to change with slider





void UpdateScreen()

{

  if (myTouch.dataAvailable()) {
    myTouch.read();
    x = myTouch.getX(); // X coordinate where the screen has been pressed
    y = myTouch.getY(); // Y coordinates where the screen has been pressed
  }

  switch (screenState)
  {
  case HOME:
    if (screenState != LastScreenstate) // run only once
    {
      myGLCD.clrScr();
      myGLCD.setBackColor(0, 0, 0); // Sets the background color of the area where the text will be printed to black
      myGLCD.setColor(255, 255, 204); // Sets color to white
      myGLCD.setFont(BigFont);
      myGLCD.print("   STBY   ", CENTER, 90); // Prints the string on the screen
      myGLCD.setColor(255, 0, 0); // Sets color to red
      myGLCD.drawLine(0, 60, 319, 60); // Draws the red line
      myGLCD.drawLine(0, 170, 319, 170); // Draws the red line
      myGLCD.setColor(255, 255, 255); // Sets color to white
      myGLCD.setFont(SmallFont); // Sets the font to small
      myGLCD.print("Time:", 0, 0); // Prints the string


      // buttons sign 
      //myGLCD.drawRoundRect(0, 185, 0 + 50, 185 + 50);
     // myGLCD.drawBitmap(10, 195, 30, 30, DiagnosticSign);
      myGLCD.drawRoundRect(265, 185, 265 + 50, 185 + 50);
      myGLCD.print("Setting",265, 185+25); // Prints the string

     // myGLCD.drawBitmap(275, 195, 30, 30, SettingsSign);

      //TrackBar
      myGLCD.setColor(255, 255, 255);
      myGLCD.fillRect(48, 20, 48 + 224, 20 + 12);

      LastScreenstate = screenState;
    }


    
  
    //if button setting was pressed (right corner button) 
    
      if ((x >= 265) && (x <= 265 + 50) && (y >= 185) && (y <= 185 + 50)) {
        screenState = SETTING;

      }

    

  case SETTING:
    if (screenState != LastScreenstate)// run only once
    {
      myGLCD.clrScr();
      myGLCD.setColor(100, 155, 203);
      myGLCD.fillRoundRect(10, 10, 60, 36);
      myGLCD.setColor(255, 255, 255);
      myGLCD.drawRoundRect(10, 10, 60, 36);
      myGLCD.setFont(BigFont);
      myGLCD.setBackColor(100, 155, 203);
      myGLCD.print("<-", 18, 15);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.setFont(SmallFont);
      myGLCD.print("Back to Main", 70, 18);
      myGLCD.setFont(BigFont);
      myGLCD.print("Setting Controll", CENTER, 50);
      myGLCD.setColor(255, 0, 0);
      myGLCD.drawLine(0, 75, 319, 75);
      myGLCD.setColor(255, 255, 255);

      
      drawSlider(40, 98, 220, 10, 0, 60, " Washing Time",int(washingTime/1000UL));

      LastScreenstate = screenState;
    }

    //Back button
    if ((x >= 10) && (x <= 60) && (y >= 10) && (y <= 36)) {
      
      washingTime = TimeChangeSlider*1000UL; // if back was pressd change the value of the global varble
      screenState = HOME;
    }

     TimeChangeSlider = updateSlider(40, 98, 220, 10, 60,x,y,int(washingTime / 1000UL));
  
    break;

  }
}

int updateSlider(int xpos,int ypos,int w, int h,int value,int xTouch,int yTouch, int CurrentValue) {
  int hight = ypos + h;
  int width = xpos + w;
  int xR ;
  int xRC;
  int mapValue;

  if ((yTouch >= ypos - 8) && (yTouch <= hight + 8)) {
    xR = xTouch; // Stores the X value where the screen has been pressed in to variable xR
    if (xR <= xpos + 3) { // Confines the area of the slider to be above 38 pixels
      xR = xpos + 3;
    }
    if (xR >= width - 7) { /// Confines the area of the slider to be under 310 pixels
      xR = width - 7;
    }
    xRC = map(xR, xpos, width, 0, 255);
    mapValue = map(xR, xpos, width, 0, value);

    myGLCD.setColor(255, 255, 255);
    myGLCD.fillRect(xR, ypos + 1, (xR + 4), hight - 1); // Positioner
    myGLCD.setColor(xRC, 0, 0);
    myGLCD.fillRect(xpos + 1, ypos + 1, (xR - 1), hight - 1);
    myGLCD.setColor(0, 0, 0);
    myGLCD.fillRect((xR + 5), ypos + 1, width - 1, hight - 1);
    int valuePos = int(width / 2);
    myGLCD.setColor(255, 255, 255);
    myGLCD.print(String(mapValue), valuePos , ypos + 15);
    //print the varible after changed
  }
  else
    mapValue = CurrentValue;
  return mapValue;
}

void drawSlider(int xpos, int ypos, int w, int h, int minValue, int maxValue, char *label,int CurrentValue) {
  int hight = ypos + h;
  int width = xpos + w;

  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRect(xpos, ypos, width, hight );
  myGLCD.setFont(SmallFont);
  int labelPos = int(width / 2);
  myGLCD.print(label, labelPos-30, ypos - 15);
  myGLCD.print(String(minValue), xpos-20, ypos);
  myGLCD.print(String(maxValue), width+10, ypos );

  // draw the last value
  int xR =map(CurrentValue, minValue, maxValue,xpos, width);
  myGLCD.setColor(255, 255, 255);
  myGLCD.fillRect(xR, ypos + 1, (xR + 4), hight - 1); // Positioner
  myGLCD.setColor(0, 200, 0);
  myGLCD.fillRect(xpos + 1, ypos + 1, (xR - 1), hight - 1);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRect((xR + 5), ypos + 1, width - 1, hight - 1);

  //print
  myGLCD.setColor(255, 255, 255);
  myGLCD.print(String(CurrentValue), labelPos, ypos + 15);
}

void setup()
{
    myGLCD.InitLCD();
    myGLCD.clrScr();
    myGLCD.setFont(SmallFont);
    myTouch.InitTouch();
    myTouch.setPrecision(PREC_MEDIUM);


}


void loop()
{

UpdateScreen();

}

Try a small delay (5-10) before
if (screenState != LastScreenstate)// run only once