 // This is our page serving function that generates web pages
 boolean sendPage(char* URL) {
   
-  Serial.println("Page printing begun");
-  
-    printStates();
-    writeStates();
+  changeStates();
     
   //check whether we need to change the led state
-  if (URL[1] == '?' && URL[2] == 'L' && URL[3] == 'E' && URL[4] == 'D') //url has a leading /
-  {
+  if (URL[1] == '?' && URL[2] == 'L' && URL[3] == 'E' && URL[4] == 'D') { //url has a leading /
     ledChange = (int)(URL[5] - 48); //get the led to change.
     
-    for (stateCounter = 0 ; stateCounter < 1; stateCounter++)
-    {
-      if (ledChange == stateCounter)
-      {
+    for (stateCounter = 0 ; stateCounter < 1; stateCounter++) {
+      if (ledChange == stateCounter) {
         states[stateCounter] = !states[stateCounter];
-            Serial.print("Have changed ");
-            Serial.println(ledChange);
-            Serial.print("Sending RFID .... ");
-            sendCode();
+        Serial.print("Sending RFID .... ");
+        sendCode();
       }
     }
     

        return true;
   }
   else {
     return true;
   }
}

// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state


    }
  }
  else if (codeType == UNKNOWN) {
    //Serial.println("Ignoring unknown code");
  }
}

void loop()
