 }
 
 void  loop(){  
-  checkOverflow();
+  CheckWaterOn();
   digitalClockDisplay();
   Alarm.delay(1000); // wait one second between clock display
 }

}

void WaterOff(){
  if (WATERON){
    Serial.println("Water OFF");
    digitalWrite(PUMP_PIN, LOW);
    WATERON = false;
  }
  lcd.setCursor(0, 1);
  lcd.print("Water OFF       ");
}

void CheckWaterOn(){
  unsigned long diff = millis() - last_fill_start;
  lcd.setCursor(0, 1);
  bool state = digitalRead(PUMP_PIN);
  
  if (state && diff > FILLTIME_MILLIS){
    lcd.print("Water too long  ");
    Serial.print("Water on passed fill time ");
    Serial.println(diff);
    Serial.println(FILLTIME_MILLIS);
    WaterOff();
  }
  else if (state && diff < FILLTIME_MILLIS) {
    lcd.print("Within fill, OK ");
    Serial.println("Within fill cycle, all OK");
  }
  else if (!state && !shitscreek && WATERON && diff < FILLTIME_MILLIS) {
    lcd.print("Resume fill, OK ");
    Serial.println("Within fill cycle, resume OK");
    digitalWrite(PUMP_PIN, HIGH);
    WATERON = true;
  }
  else {
    lcd.print("Water off, OK   ");
    Serial.println("Water off, all OK");
    WaterOff();
  }
}

void checkOverflow()
{
  Serial.println(digitalRead(OVERFLOW_PIN));
  lcd.setCursor(0, 1); 
  if (digitalRead(OVERFLOW_PIN) == LOW) {
    shitscreek = true;
    lcd.print("WATER OVERFLOW!!");
    digitalWrite(PUMP_PIN, LOW);
    //WaterOff();
  }
  else {
    if (shitscreek == true) {
      shitscreek = false;
      CheckWaterOn();
    }
  }
}


unsigned long last_fill_start;

int OVERFLOW_PIN = 2;

void setup()
{
  pinMode(PUMP_PIN, OUTPUT);
  digitalWrite(PUMP_PIN, HIGH);
  pinMode(OVERFLOW_PIN, INPUT);
  
  // LCD Setup
