     // change the tilt of the tray
 
     isTrayTiltTimerComplete = false;
-    tiltTray();
+    stopMotorTimer();
     state = TRAY_TILTING;
+    if (currentMotorPosition == LEFT) {
+      tiltMotor(RIGHT);
+    } else {
+      tiltMotor(LEFT);
+    }
+    startMotorTimer();
+    state = IDLE;
   }
   ArduinoOTA.handle();
-  //delay(300);
-  //delay(5000);
 }
 
 // Timer Call Backs
 
 void environmentTimerFinished(void *pArg) {
+  // don't do too much in here. Just set the state
+  // and handle it in the main loop
   isEnvironmentTimerComplete = true;
 }
 

// *************************************************************

void loop() {

  // read Motor Switches
  int motorSwitchLeft = digitalRead(PORT_MOTOR_SWITCH_LEFT);
  int motorSwitchRight = digitalRead(PORT_MOTOR_SWITCH_RIGHT);

  // TODO: Capture the state of the motor
  // so we know when to just stop and wait or
  // we're just taking off
  
  if (motorSwitchLeft == HIGH) {
    switchOffMotor();
    publishDebug("Motor Switch Left is HIGH");
    lcdStatus("Motor SW Left High");
    delay(100);
  }
  if (motorSwitchRight == HIGH) {
    switchOffMotor();
    publishDebug("Motor Switch Right is HIGH");
    lcdStatus("Motor SW Right High");
    delay(100);
  }

  switch (state) {
    case MOTOR_SWITCH_DETECTED:
      digitalWrite(BUILTIN_LED, HIGH);
      motorSwitchAction();
      break;
    // case TIMER_SWITCH_ACTIVATED:
    //   timerSwitchAction();
    default:
      break;
  }

  if (isEnvironmentTimerComplete == true) {
    isEnvironmentTimerComplete = false;



  // Hostname defaults to esp8266-[ChipID]
    ArduinoOTA.setHostname(IOT_DEVICE_ID);

  // No authentication by default
  // ArduinoOTA.setPassword((const char *)"123");
