fixed the function compute_chi_all