TSOP322 trouble with using as break beam sensors

I am using two tsop cheap 38khz ir modules as break beam sensors. when a beam is detected broken it lights up the stairs in order (up and down functions)
I had trouble with marks on ken sheffis blog. I used grumpy mikes timer based mark system to keep the tsop happy however i am having trouble with the timing of the whole thing.

I think when i call a funtion after detectiong the lack of a mark, it screws up the timing and the module "sticks "?

any suggestions as to how i can clean this up and make it realiable? i want it to trigger immediately after sensing the lack of beam.

i am using pin3 as the ir led and it works ok just sticks after the function up.

unsigned long uSecsOld = 0;
boolean markFlag = true;
unsigned int markTime = 1000; //uSecs
unsigned int spaceTime =2000; //uSecs

void setIrModOutput() {                            // sets pin 3 going at the IR modulation rate
  TCCR2A = 0xF0 | _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(WGM22) | _BV(CS21);
  OCR2A = 51;                                      // defines the frequency 51 = 38.4 KHz, 54 = 36.2 KHz, 58 = 34 KHz, 62 = 32 KHz, 66 = 30KHz, 33 = 60 KHz
  OCR2B = 26;                                      // deines the duty cycle - Half the OCR2A value for 50%
}



 
int led6 = 7;
int led7 = 8;
int led8 = 9;
int led9 = 10;
int led10 = 11;
int led11 = 12;
int led12 = 13;


void setup() {

  
  setIrModOutput();
  pinMode(03, OUTPUT);                             // Just enable output on Pin 3 and disable it on Pin 11
  pinMode(13, OUTPUT);
  pinMode(2, INPUT);  
  pinMode(1, INPUT); 
  uSecsOld = micros();


}

void loop(){
 


if (markFlag && ((micros() - uSecsOld) > markTime) ) {
    //end of MARK
    uSecsOld = micros();
    OCR2B = OCR2A; //set SPACE
    markFlag = false;
    
    
  }
  else if (!markFlag && ((micros() - uSecsOld) > spaceTime) ) {
    //end of SPACE
    uSecsOld = micros();
   OCR2B = 44; //set MARK
    markFlag = true;
    delay(1);
   
   
      if (digitalRead(2)) {digitalWrite(13, HIGH); up();
    OCR2B = OCR2A; //set SPACE
    markFlag = false;} else digitalWrite(13, 0);
 
  
    
  }}

void up(){  delay (200); 
    
//  digitalWrite(led6, HIGH);
//  delay(288);
//  digitalWrite(led7, HIGH);
//  delay(288);
//  digitalWrite(led8, HIGH);
//  delay(288);
//  digitalWrite(led9, HIGH);
//  delay(288);
//  digitalWrite(led10, HIGH);
//  delay(288);
//  digitalWrite(led11, HIGH);
//  delay(288);
//  digitalWrite(led12, HIGH);
//  delay(5000);
//  
//  delay(1200);
//  digitalWrite(led6, LOW);   
//    delay(1200);                  
//  digitalWrite(led7, LOW);  
//  delay(1100);
//  digitalWrite(led8, LOW);   
//  delay(1100);           
//    digitalWrite(led9, LOW);    
//  delay(1100);
//  digitalWrite(led10, LOW); 
//  delay(900);                   
//    digitalWrite(led11, LOW);   
//  delay(850);
//  digitalWrite(led12, LOW);  

//
//} 
// void down(){ 
//  
//  digitalWrite(led12, HIGH);
//  delay(288);
//  digitalWrite(led11, HIGH);
//  delay(288);              
//  digitalWrite(led10, HIGH);    
//  delay(288);
//  digitalWrite(led9, HIGH);   
//  delay(288);                  
//  digitalWrite(led8, HIGH);   
//  delay(288);
//  digitalWrite(led7, HIGH);  
//  delay(288);
//  digitalWrite(led6, HIGH);
//  delay(288);
//  
//  delay(5000);                    
//  digitalWrite(led12, LOW);    
//  delay(1200);
//  digitalWrite(led11, LOW);   
//  delay(1200);                  
//digitalWrite(led10, LOW);    
//  delay(1100);
//  digitalWrite(led9, LOW);   
//  delay(1100);                   
//    digitalWrite(led8, LOW);     
//  delay(1100);
//  digitalWrite(led7, LOW);    
//    delay(900);                  
//  digitalWrite(led6, LOW);     
//  delay(850);

  }

I probably should have used a regular ir photodiode and counted pulses as suggested eselwhere but this is what i have installed on location and would like to use this hardware!!

thanks alot and merry christmas to the forum!!!

mike ebike