In this paper, extending past works of Del Popolo, we show how a high precision mass function (MF) can be obtained using the excursion set approach and an improved barrier taking implicitly into account a non-zero cosmological constant, the angular momentum acquired by tidal interaction of proto-structures and dynamical friction. In the case of the ΛCDM paradigm, we find that our MF is in agreement at the 3% level to Klypin's Bolshoi simulation, in the mass range M vir = 5 × 10 9 h −1 M -5 × 10 14 h −1 M and redshift range 0 z 10. For z = 0 we also compared our MF to several fitting formulae, and found in particular agreement with Bhattacharya's within 3% in the mass range 10 12 − 10 16 h −1 M . Moreover, we discuss our MF validity for different cosmologies.