fix timing function