speed up the computation for Betti numbers