Error Trace 0 starts too late using xcorr_pick_correction

Dear obspy community,

I am trying to align the waveforms using cross correlation after selecting a fix window with reference to first arrival using concept from This link . Each trace is 30 seconds long with both P and S arrival.
I found that my code works very well for some traces of events but later, it gives errors for otehr traces even using same parameters.
Exception: Trace 0 starts too late.,

I have tried to further read the code and found that there is a very minor difference in tr.stats.starttime and start as mention below:

tr.stats.starttime = 2020-06-01T20:10:06.353000Z, start= 2020-06-01T20:10:05.403000Z
if tr.stats.starttime > start:
msg = “Trace %s starts too late.” % _i
raise Exception(f"{msg}, {tr.stats.starttime },{start}")
if tr.stats.endtime < end:
msg = “Trace %s ends too early.” % _i

 My Code looks like :
    t1  = st1[0].stats.starttime
    P1  = st1[0].stats.sac.a
    dist= st1[0].stats.sac.user3                    #distance from fault center
    t2  = st2[0].stats.starttime
    sta2  = st2[0].stats.sac.kstnm
    P2  = st2[0].stats.sac.a
    tr1 = st1[0].trim(starttime=t1+P1,endtime=t1+P1+3)
    tr2 = st2[0].trim(starttime=t2+P2,endtime=t2+P2+3)
    dt, coeff = xcorr_pick_correction(t1+P1, tr1, t2+P2, tr2, 0.5, 0.2, 0.9)

Is there any suggestion to overcome this issue?

You specify the times of the picks exactly at the start of the waveforms you input, that can’t work. Your pick/phase onsets should be like in the middle of the waveform you input, so that the cross correlation has data before/after the pick to use