           digitalWrite(level, LOW); 
           setRef = true;       
         } else {
-          //Test to see if moving here
-          
-          if(abs(abs(xDeg)-abs(refX)) < 8 && abs(abs(zDeg)-abs(refZ)) < 8) {
+          if(abs(dx) > 20 || abs(dy) > 20 || abs(dz) > 20) {
+            digitalWrite(tilted, LOW);
+            digitalWrite(moving, HIGH);
+            digitalWrite(level, LOW);
+          } else if(abs(abs(zDeg)-abs(refZ)) < 8) {       //abs(abs(xDeg)-abs(refX)) < 8 && 
             digitalWrite(tilted, LOW);
             digitalWrite(moving, LOW);
             digitalWrite(level, HIGH);

        int modz = dz%10;
        dz = dz-modz;
    
        tempx = ax;
        tempy = ay;
        tempz = az;
 */   
        if(count < calibrateCount) {
          count++;
          if(count%100 < 50) {

            digitalWrite(moving, LOW);
            digitalWrite(level, LOW);
          }
          /*
          else if(abs(abs(xDeg)-abs(refX)) > 15) {
            digitalWrite(tilted, HIGH);
            digitalWrite(moving, LOW);
            digitalWrite(level, LOW);
          } 
           */
        }
        

        // blink LED to indicate activity
        blinkState = !blinkState;
