How do you plan to solve it?

const int BUTTON =4;
int laststate=HIGH;
unsigned long presstime=0;
unsigned long releasetime=0;
bool doublec=false;
void setup() {
Serial.begin(115200);
pinMode(BUTTON,INPUT_PULLUP);
}
void loop() {
int currentstate=digitalRead(BUTTON);
if (laststate==HIGH&¤tstate==LOW){
presstime=millis();
}
if(laststate==LOW&¤tstate==HIGH){
unsigned long about=millis()-presstime;
if (about>50){
if(about<1000){
if (doublec&&millis()-releasetime<250){
Serial.println("Double click!");
doublec=false;
}else{
doublec=true;
}
releasetime=millis();
}
}
}
if(currentstate==LOW&&millis()-presstime>1000){
static bool longpress=false;
if(!longpress){
Serial.println("LOng click");
longpress=true;
doublec=false;
}
if (currentstate==HIGH) longpress=false;
}
if(doublec&&millis()-releasetime>250){
Serial.println("single click!");
doublec=false;
}
laststate=currentstate;
}