Corrected timing function