The simple, conventional dark matter halo mass definitions commonly used in cosmological simulations ('virial' mass, FoF mass, M50, 100, 200, …) only capture part of the collapsed material and are therefore inconsistent with the halo mass concept used in analytical treatments of structure formation. Simulations have demonstrated that typical dark matter particle orbits extend out to about 90 per cent of their turnaround radius, which results in apocentre passages outside of the current 'virial' radius on the first and also on the second orbit. Here we describe how the formation history of haloes can be used to identify those particles which took part in the halo collapse, but are missed by conventional group finders because of their remote present location. These particles are added to the part of the halo already identified by FoF. The corrected masses of dark haloes are significantly higher (the median mass increase is 25 per cent) and there is a considerable shift of the halo mass function towards the Press and Schechter form. We conclude that meaningful quantitative comparisons between (semi-)analytic predictions of halo properties (e.g. mass functions, mass accretion rates, merger rates, spatial clustering, etc.) and simulation results will require using the same halo definition in both approaches.