           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) {

            Serial.print("\tCount: ");
            Serial.println(count);


            // display real acceleration, adjusted to remove gravity
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetAccel(&aa, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
//            Serial.print("areal\t");
//            Serial.print(aaReal.x);
//            Serial.print("\t");
//            Serial.print(aaReal.y);
//            Serial.print("\t");
//            Serial.print(aaReal.z);
//            Serial.print("\t");
  
        // Set acceleration values here
        accelX = aaReal.x;
        accelY = aaReal.y;
        accelZ = aaReal.z;
        dx = abs(accelX) - abs(tempx);
        dy = abs(accelY) - abs(tempy);
        dz = abs(accelZ) - abs(tempz);
        
        dx = (dx/10);               
        int modx = dx%10;
        dx = dx-modx;
