The eddy covariance (EC) method is a standard micrometeorological technique for monitoring the exchange rate of the main greenhouse gases across the interface between the atmosphere and ecosystems. One of the first EC data processing steps is the temporal alignment of the raw, high frequency measurements collected by the sonic anemometer and gas analyser. While different methods have been proposed and are currently applied, the application of the EC method to trace gases measurements highlighted the difficulty of a correct time lag detection when the fluxes are small in magnitude. Failure to correctly synchronise the time series entails a systematic error on covariance estimates and can introduce large uncertainties and biases in the calculated fluxes. This work aims at overcoming these issues by introducing a new time lag detection procedure based on the assessment of the cross-correlation function (CCF) between variables subject to (i) a pre-whitening based on autoregressive filters and (ii) a resampling technique based on block-bootstrapping. Combining pre-whitening and block-bootstrapping facilitates the assessment of the CCF, enhancing the accuracy of time lag detection between variables with correlation of low order of magnitude (i.e. lower than -1\\documentclass[12pt]{minimal} \\usepackage{amsmath} \\usepackage{wasysym} \\usepackage{amsfonts} \\usepackage{amssymb} \\usepackage{amsbsy} \\usepackage{mathrsfs} \\usepackage{upgreek} \\setlength{\\oddsidemargin}{-69pt} \\begin{document}$$-1$$\\end{document}) and allowing for a proper estimate of the associated uncertainty. We expect the proposed procedure to significantly improve the temporal alignment of the EC time-series measured by two physically separate sensors, and to be particularly beneficial in centralised data processing pipelines of research infrastructures (e.g. the Integrated Carbon Observation System, ICOS-RI) where the use of robust and fully data-driven methods, like the one we propose, constitutes an essential prerequisite.