Code efficiency using IF's - Password Box

So I have a project that I pieced together from another write-up and overall it works great, but it is occassionally a little slow and I am pretty sure my code isn’t the most efficent. Is anyone able to review this and let me know if there is a better way to write this, or even a better function to use? I am still pretty new to coding Arduinos so spoon feeding is a plus!

The basics are:
Arduino Leonardo and Adafruit PN532 RFID/NFC (+1 LED & Resistor)
The arduino boots into a locked state (LED on) where any defined RFID/NFC codes will spit out a false password (I removed all but the first in code below to shorten it). When the key NFC is used, it will unlock the arduino (LED off) and allow you to use the defined codes for passwords/phrases. Using the key again will lock the arduino again (LED on). This all works great, it just gets slow sometimes and I imagine that my code is the culprit; My definition of slow is more than a couple seconds. I currently have 6 passwords and their locked state versions loaded.

//Largely based on Lewis Callaway’s Instructable code:

#include <Adafruit_PN532.h>
#include <Wire.h>
#include <SPI.h>
#include <Keyboard.h>

#define IRQ 6 // this trace must be cut and rewired to work on Leonardo
#define RESET 8
unsigned int NFCLock;

Adafruit_PN532 nfc(IRQ, RESET);

void setup() {

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x Board");
    while (1); // halt
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata >> 24) & 0xFF, HEX);
  Serial.print("Firmware ver."); Serial.print((versiondata >> 16) & 0xFF, DEC);
  Serial.print("."); Serial.println((versiondata >> 8) & 0xFF, DEC);
  // configure board to read RFID tags
  Keyboard.begin(); //initiate the keyboard
  pinMode(LED_BUILTIN, OUTPUT); //Initialize digital pin LED_BUILTIN as an output
    digitalWrite(LED_BUILTIN, HIGH); //Turn LED on
    //pinMode(13, OUTPUT) && digitalWrite(13, HIGH) - BuiltIn & 13 are linked on Leonardo?

unsigned digit = 0;

void loop() {
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
  uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // wait for RFID card to show up!
  Serial.println("Waiting for an ISO14443A Card ...");

  // Wait for an ISO14443A type cards (Mifare, etc.). When one is found
  // ‘uid’ will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

  uint32_t cardidentifier = 0;
  if (success) {
    // Found a card!

    Serial.print("Card Detected #");
    // turn the four byte UID of a mifare classic into a single variable #
    cardidentifier = uid[3];
    cardidentifier <<= 8; cardidentifier |= uid[2];
    cardidentifier <<= 8; cardidentifier |= uid[1];
    cardidentifier <<= 8; cardidentifier |= uid[0];
    Serial.print("NFC Lock before ");
    Serial.println (NFCLock);

    if (cardidentifier == 123456 && NFCLock == 0) { //NFC "key" - Unlock Function
      NFCLock = 1; //Unlocks
      digitalWrite(LED_BUILTIN, LOW); //Turn LED off
      Serial.print("NFC Lock inside Unlock Function ");
      cardidentifier = 0; //This prevents the next IF from being immediately trigerred and re-locking the device
      delay(1500); //makes sure the unlock/lock isn’t repeated
                  if (cardidentifier == 123456 && NFCLock == 1) { //NFC "key" - Lock Function
                    NFCLock = 0; //Locks again
                    digitalWrite(LED_BUILTIN, HIGH); //Turn LED on
                    Serial.print("NFC Lock inside Lock Function ");
    if (cardidentifier == 101 && NFCLock == 1) { // NFC-1
      Keyboard.print("Phrase 1"); //Password 1
      digitalWrite(LED_BUILTIN, HIGH); //Turn LED on
      delay(1500); //makes sure the password isn’t repeated
      digitalWrite(LED_BUILTIN, LOW); //Turn LED off
                  //--This was a "sub" IF to give a response if the arduino was in a locked state
                  //if (cardidentifier == 101 && NFCLock == 0) { // NFC-1 
                    //Keyboard.print("I am locked. Please unlock me first."); //Fake Password
                    //digitalWrite(LED_BUILTIN, LOW); //Turn LED off
                    //digitalWrite(LED_BUILTIN, HIGH); //Turn LED on
    if (cardidentifier == 102 && NFCLock == 1) { // NFC-2
      Keyboard.print("Phrase 2");
      digitalWrite(LED_BUILTIN, HIGH); //Turn LED on
      digitalWrite(LED_BUILTIN, LOW); //Turn LED off

    if (cardidentifier == 103 && NFCLock == 1) { // NFC-3 
      Keyboard.print("Phrase 3");
      digitalWrite(LED_BUILTIN, HIGH); //Turn LED on
      digitalWrite(LED_BUILTIN, LOW); //Turn LED off


This all works great, it just gets slow sometimes and I imagine that my code is the culprit;

I imagine that the 1.5 second delay() when the key card is presented will not be helping

You could prevent the lock/unlock repeating by detecting that the card has [u]become[/u] present rather than when it [u]is[/u] present.

I should have clarified, the slowness is in actually reading an NFC at all. I have to hold my NFC tag for a couple seconds before I get a result. Once the IF statement starts it immediately types in the password, flips the LED on, and starts the delay, but intializing that IF is the slower part. The delay is at the end of the IF statements, so it's only ever executed if the statement is run so I don't think that should be the issue, right?

Can you elaborate on the become present vs is present for lock status?

Edit: I also guessed there was a poor connection/blockage, but when reducing the amount of IF statements to take 1 password I saw quicker results so I think it is in the code, not the hardware.