Modified method perform_chi_square