  We present a new method for estimating the H2 cooling rate in the optically
thick regime in simulations of primordial star formation. Our new approach is
based on the TreeCol algorithm, which projects matter distributions onto a
spherical grid to create maps of column densities for each fluid element in the
computational domain. We have improved this algorithm by using the relative gas
velocities, to weight the individual matter contributions with the relative
spectral line overlaps, in order to properly account for the Doppler effect. We
compare our new method to the widely used Sobolev approximation, which yields
an estimate for the column density based on the local velocity gradient and the
thermal velocity. This approach generally underestimates the photon escape
probability, because it neglects the density gradient and the actual shape of
the cloud. We present a correction factor for the true line overlap in the
Sobolev approximation and a new method based on local quantities, which fits
the exact results reasonably well during the collapse of the cloud, with the
error in the cooling rates always being less than 10%. Analytical fitting
formulae fail at determining the photon escape probability after formation of
the first protostar (error of 40%) because they are based on the assumption of
spherical symmetry and therefore break down once a protostellar accretion disc
has formed. Our method yields lower temperatures and hence promotes
fragmentation for densities above 10^{10}/ccm at a distance of 200AU from the
first protostar. Since the overall accretion rates are hardly affected by the
cooling implementation, we expect Pop III stars to have lower masses in our
simulations, compared to the results of previous simulations that used the
Sobolev approximation.
