improve framenumber function speed wich was taking 10% of the time