tweaked timing function