issue with Variable reset

Hi i have an issue with the sketch for my security system that i am building . its been 2 days that i am trying to get things to work the way i want it to. The issue is that the time to reset the "trigger" Variable to 1 after say 3000(mills) is not working correctly. it changes the value at random intervals. I have tried the mills() function and now tried with Metro as well but both almost the same result. =(

Sounds like you made one or more mistakes in your programming.

In general, when you are seeking help for a sketch that is not working as you expect you should show your code.

Sorry about that the code below

#include <Metro.h>
#include <Password.h>
#include <Keypad.h>
#include <SoftwareSerial.h>
SoftwareSerial rfid_reader(3,4);

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
{‘1’,‘2’,‘3’},
{‘4’,‘5’,‘6’},
{‘7’,‘8’,‘9’},
{’#’,‘0’,’*’}
};
byte rowPins[ROWS] = { 9, 8, 7, 6 };
byte colPins[COLS] = { 12, 11, 10 };
boolean trigger = 1;
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
Password password = Password(“300613”); // setting the password

char tag =“8*********5”; // The Tag ID
char input[12]; // A Variable to store the ID of the Tag being presented
int count = 0; // A counter variable to navigate through the input character array
boolean flag = 0; // A variable to store the Tag match status
boolean state = 0; // A variable to store the state of the Led to be toggled
boolean tag_ready=0; // A variable that is set by the ISR when an interrupt occurs
Metro trgMetro = Metro(3000);

void setup()
{

rfid_reader.begin(9600);
Serial.begin(9600);

pinMode(2,INPUT); // Interrupt Pin defined as Input
attachInterrupt(0, check, FALLING); // Enable the Interrupt to call the ISR check when a Falling Interrupt occurs

Serial.begin(9600);
keypad.addEventListener(keypadEvent);

}

void loop()
{

keypad.getKey();

if(tag_ready) // Check if the variable is set
{
process_tag(); // if the variable is set, call the process_tag() function
}
Serial.println(trigger);
chktrigger();
}

//check the keypad events
void keypadEvent(KeypadEvent keyPress)
{
switch (keypad.getState())
{
case PRESSED:
switch (keyPress)
{
case ‘#’:
checkPassword();
break;

case ‘*’:
password.reset();
break;

default:
password.append(keyPress);
}
}
}

//check the entered password
void checkPassword(){
if (password.evaluate())
{
Serial.println(“Correct Password”);
trigger = 0;
chktrigger();

}
else
{
Serial.println(" Wrong Password");
trigger = 1;
password.reset();
}
}

void process_tag()
{
if(rfid_reader.available())// Check if there is Incoming Data in the RFID Reader Serial Buffer.
{
count = 0; // Reset the counter to zero
while(rfid_reader.available() && count < 12)
{
input[count] = rfid_reader.read(); // Read 1 Byte of data and store it in the input variable
count++; // increment counter
delay(5);
}
if(count == 12)
{
count =0; // reset counter varibale to 0
flag = 1;
while(count<12 && flag !=0)
{
if(input[count]==tag[count])
flag = 1; // everytime the values match, we set the flag variable to 1
else
flag=0; // if the ID values don’t match, set flag variable to 0 and stop comparing by exiting the while loop
count++; // increment i
}
}
if(flag == 1) // If flag variable is 1, then it means the tags match
{
Serial.println(“Matched!”);
state = !state; // Toggle state
trigger = 0 ;

}
else
{
Serial.println(“Wrong Tag”); // Incorrect Tag Message
trigger = 1;
}

for(count=0; count<12; count++) // Fill the input variable array with a fixed value ‘F’ to overwrite all values getting it empty for the next read cycle
{
input[count]= ‘F’;
}
count = 0; // Reset counter variable
}
tag_ready=0;
}

void check() // The Interrupt Service Routine
{

tag_ready = 1; // Set the tag_ready variable

}

void chktrigger()

{

if (trgMetro.check() == 1) {
if (trigger == 0) {
trigger = 1 ;
trgMetro.interval(3000);
} }

}

got the fix.. Used MStimer2