pattern timing function written in timing.c. Tested