timing algorithm working