Question about on/off led with (RFID module)

I am recently introduced to arduino forum. I am in the middle of a projects that requires to open and close various kinds of leds using an RFID module(MF522-AN).

The code which is compatible with the RFID is the following:www.grantgibson.co.uk/blog/wp-content/uploads/2012/04/ggrfid.ino_.zip

I have changed the above mentioned code by making comment the code that i do not need. The problem i am facing at the moment, is regarding the following code:

       if(serNum[0] == 163 )  {
                          Serial.println("card");
                          digitalWrite(card,HIGH);
                       }  
                        else if(serNum[0] == 147 ) {
                          Serial.println("card2");
                          digitalWrite(card2,HIGH);
                        }
                        else if(serNum[3] == 168){
                         Serial.println("card1");
                       digitalWrite(card1,HIGH);}

With this code i am able to open the leds with relevant card (first pass) but i cannot close the led by passing the card for the second time.

Grateful if you could provide me me with advice and recommendations.

Best regards,

Andreas

but i cannot close the led by passing the card for the second time.

Why can't you?

       if(serNum[0] == 163 )  {
                          Serial.println("card");
                          cardState = !cardState;
                          digitalWrite(card,cardState);
                       }

Where cardState is a boolean, initialized to false.