     recv[i++] = WIRE.read();
     recvq = true;
   }
-  if ((recv[1] << 8) + recv[2] == SET_BACPAC_3D_SYNC_READY) {
+  if (i > 3 && (recv[1] << 8) + recv[2] == SET_BACPAC_3D_SYNC_READY) {
     switch (recv[3]) {
     case 1:
       ledOn();

    recv[i] = WIRE.read();
    recvq = true;
  }
  if ((recv[1] << 8) + recv[2] == SET_BACPAC_3D_SYNC_READY) {
    switch (recv[3]) {
    case 1:
      ledOn();

    recv[i++] = WIRE.read();
    recvq = true;
  }
  if (i > 3 && (recv[1] << 8) + recv[2] == SET_BACPAC_3D_SYNC_READY) {
    switch (recv[3]) {
    case 1:
      ledOn();
