i think the biggest time waist of this sub routine is waiting for a pulsin to see an input transition ,there is no time out on the command.

As it happens because the input is connected to IR receiver , and some transient spikes do occur it gets to check the pulse and then return from the routine , generally with a sec

I think ill add a timeout value so that it not waiting for input to occur , see if that improves it