   }
 
   // now we trigger MOSFETs off or on
-  Serial.print("Growbed Valve Air Pump ");
-  Serial.print(pumpNum);
-  if(newState == true){
-    mcp.digitalWrite(mcpPin, HIGH);
-    Serial.println(" on");
-  } else {
-    mcp.digitalWrite(mcpPin, LOW);
-    Serial.println(" off");
-  }
+  swapPumpState(pumpNum, newState, mcpPin);
 
   toSend += "<h2>Water Pump ";
   toSend += pumpNum;


/////////////////////////////////////////////////////////////////////////////
// misc utils ///////////////////////////////////////////////////////////////
void ledOn() { digitalWrite(BUILTIN_LED, LOW); }
void ledOff() { digitalWrite(BUILTIN_LED, HIGH); }
void blink(int times) {
  ledOff();

  toSend += ".)</p>\n";
  toSend += pageFooter;
  webServer.send(200, "text/html", toSend);
}
void swapPumpState(int pumpNum, boolean newState, int mcpPin) {
  Serial.print("Growbed Valve Air Pump ");
  Serial.print(pumpNum);

  if(newState == true){
    mcp.digitalWrite(mcpPin, HIGH);
    Serial.println(" on");
  } else {
    mcp.digitalWrite(mcpPin, LOW);
    Serial.println(" off");
  }
}

/////////////////////////////////////////////////////////////////////////////
