The abundance of galaxy clusters can constrain both the geometry and growth of structure in our Universe. However, this probe could be significantly complicated by recent claims of nonuniversality -non-trivial dependences with respect to the cosmological model and redshift. In this work we analyse the dependance of the mass function on the way haloes are identified and establish if this can cause departures from universality. In order to explore this dependance, we use a set of different N-body cosmological simulations (Le SBARBINE simulations), with the latest cosmological parameters from the Planck collaboration; this first suite of simulations is followed by a lower resolution set, carried out with different cosmological parameters. We identify dark matter haloes using a Spherical Overdensity algorithm with varying overdensity thresholds (virial, 2000ρ c , 1000ρ c , 500ρ c , 200ρ c and 200ρ b ) at all redshifts. We notice that, when expressed in term of the rescaled variable ν, the mass function for virial haloes is a nearly universal as a function of redshift and cosmology, while this is clearly not the case for the other overdensities we considered. We provide fitting functions for the halo mass function parameters as a function of overdensity, that allow to predict, to within a few percent accuracy, the halo mass function for a wide range of halo definitions, redshifts and cosmological models. We then show how the departures from universality associated with other halo definitions can be derived by combining the universality of the virial definition with the expected shape of the density profile of halos.