       if ((freg == 1) && (now == 0xFF))
       {
         // bail early if all on (removed)
-        state = STATE_REMOVED;
+        state = STATE_REMOVING;
         //Serial.println(state);
       }
       // wait for all paper

      // check for early card removal (all reading holes)
      if ((freg == 1) && (now == 0xFF))
      {
        state = STATE_REMOVED;
        //Serial.println(state);
      }
      else

#define LED_D1       14
#define LED_D0       15

// Set to 8, will only read IN phase
// Set to 16, will read and collect OUT phase also
// Must see all CARD_ROWS rows to get a OK report
// if less rows read, will get an error, but data still included
// This allows host to compare IN and OUT phases and error correct
#define CARD_ROWS    16

#define REPORT_OK_BOOT       0x00
#define REPORT_OK_CARD       0x01
#define REPORT_OK_STATE      0x02
#define REPORT_OK_ROW        0x03
#define REPORT_ERR_LENGTH    0x81

typedef enum 
{
  STATE_NOCARD = 0,
  STATE_INSERTING,
  STATE_WAITING_ROW,
  STATE_IN_ROW,
  STATE_GAP,
  STATE_REMOVING,
  STATE_END
} STATE;

byte sticky = 0;
boolean seenReg = false;
byte row = 0;
byte card[CARD_ROWS];
unsigned int adc[NUM_CHANNELS];
STATE state = STATE_NOCARD;
STATE prev = STATE_NOCARD;


void setup()
