   pinMode(PIRsensorPin,INPUT); 
   pinMode(ALARMbutton,INPUT); 
   pinMode(RELAYbutton,INPUT); 
-  pinMode(RELAYpin, OUTPUT); 
   pinMode(BUZZpin, OUTPUT); 
   Serial.begin(9600); 
   wifiSEND.begin(9600); loadScreen(loadTime); loadTime++; 
-
+  
 
   lcd.setCursor(0,0); lcd.print("Resetting...             ");
   for( loadTime = 2 ; loadTime < 10; ++loadTime)
     loadScreen(loadTime); 
+
+
+
   
   char bufferr[300]; 
+  wifiSEND.sendCommand(F("AT"), bufferr, sizeof(bufferr)); delay(50); 
+  if(DEBUG) 
+    Serial.println(bufferr);
+    
   wifiSEND.sendCommand(F("AT+CWJAP?"), bufferr, sizeof(bufferr));
-  delay(5000); 
+  delay(2000); 
   if(DEBUG){ 
     Serial.println(bufferr);
     Serial.println(ESP8266_SSID);     
   }
 
-  if(bufferr!=ESP8266_SSID){ 
-  char buffer11[300]; 
-  wifiSEND.sendCommand(F("AT+RST"), buffer11, sizeof(buffer11)); 
-  delay(5000); 
+  if(bufferr[0]!=ESP8266_SSID[0] || bufferr[1]!=ESP8266_SSID[1] || bufferr[2]!=ESP8266_SSID[2]){ 
+  wifiSEND.sendCommand(F("AT+RST"), bufferr, sizeof(bufferr)); 
+  delay(1000); 
   wifiSEND.setupAsWifiStation(ESP8266_SSID, ESP8266_PASS, &Serial); 
   delay(5000); 
-  } 
+  }
   
   lcd.setCursor(0,0); lcd.print("Connecting...             "); 
   for( loadTime = 10 ; loadTime < 16; ++loadTime)

      lcd.setCursor(0,1); 
      lcd.print("         OFF!     "); 
      setColor(0,0,0); 
      digitalWrite(RELAYpin,LOW); 
    }
    delay(900); 
    if(lastON){
      r++; r%=2; 
    }
  }
  lastON=digitalRead(RELAYbutton); 

  
  if(digitalRead(PIRsensorPin)){ // motion sense 
    if(DEBUG) Serial.println("Somebody is in this area!"); 

      lcd.setCursor(0,1); lcd.print(" armed in         "); 
      delay(1000); 
      
      for( int i = 19 ; i>=0 ; --i ){
        lcd.setCursor(12,1);
        if(i<10) lcd.setCursor(11,1);
        lcd.print(i); lcd.print("         "); 
