performance improved while computing betti_number