 #define BLINK_COUNT 1
 #define BLINK_DURATION 500
 
+#define ESP_ACTIVE false
+
 String commandLock = "GET /log_visit_state/0 HTTP/1.0\r\n\r\n";
 String commandUnlock = "GET /log_visit_state/1 HTTP/1.0\r\n\r\n";
 
-int count;
-int lastState;
-int courtesyDelay = 6;
-long lastStateTimestamp;
-
-
-// sometimes you want to run with leds only
-boolean espActive = false;
+int gCount;
+int gLastState;
+int gCourtesyDelay = 6;
+long gLastStateTimestamp;
 
 void setup() {
 

  digitalWrite(YELLOW, LOW);
  digitalWrite(GREEN, LOW);
  
  if (espActive) {
    if (!sendATConnectServer()) return false;
    if (!sendATPrepareLockDoor()) return false;
    if (!sendATLockDoor()) return false;

  if (!sendATJoinNetwork()) blinkLEDForever();
  blink(BLINK_COUNT, BLINK_DURATION, 1, 1, 1);
}
void loop() {
  if (gLastState == LOW) {
    gCount++;
  } else if (gCount > 0) { 
      gCount -= gCourtesyDelay;
      digitalWrite(RED, LOW);
      digitalWrite(YELLOW, HIGH);
      digitalWrite(GREEN, LOW);
  } else {
      gCount = 0;
      digitalWrite(RED, LOW);
      digitalWrite(YELLOW, LOW);
      digitalWrite(GREEN, HIGH);
