   }
   else if (digitalRead(OffButton) == HIGH && debounceDigitalRead(OffButton) == HIGH) {
     //Serial.println("Detected off button press");
-    if (alarmActive) {
+    if (alarmActive && soundAlarmAPlaying) {
+      soundAlarmA(false);
+      snoozeActive = true;
+    }
+    else if (alarmActive) {
       alarmActive = false;
       alarmEnabled = false;
       soundAlarmA(false);
+      snoozeActive = false;
       turnLightOff();
-      waitForButtonDepress(OffButton, HIGH);
     }
     else if (sunSetActive) {
       sunSetActive = false;
       turnLightOff();
-      waitForButtonDepress(OffButton, HIGH);
     }
     else {
-      setColorForSunDown();
-      setSunSet();
-    }
+      // do nothing
+    }
+    waitForButtonDepress(OffButton, HIGH);
   }
   else if (digitalRead(rotaryButton) == LOW && debounceDigitalRead(rotaryButton) == LOW) {
     //Serial.println("Detected rotary button press, calling updateBrightness()");
-    updateBrightness();
+    //updateBrightness();
+    setSunSet();
   }
 
   if (digitalRead(alarmMasterSwitch) == LOW) {

}


bool readSunDownDeltaFromEEPROM() {
  if (eeprom.isPresent()) {
    char buf[1];
    eeprom.ReadMem(sundown_address, buf, 1);
    defaultSunSetDelta = static_cast<int>(buf[0]);
    return true;
  }
  return false;
}

bool writeSunDownDeltaToEEPROM() {
  if (eeprom.isPresent()) {
    char myBuf[1];
    myBuf[0] = static_cast<char>(defaultSunSetDelta);
    eeprom.WriteMem(sundown_address, myBuf, 1);
    return true;
  }
  return false;

const int rewind_delay = 150;
const uint32_t millisecondsIn30Minutes = 1800000;

int defaultSunSetDelta = 10; // minutes
int sunSetDimLevel = 100; // 100 = max bright, 0 = off

const uint32_t modeInactivePeriod = 30000; // 30 seconds

