added code so that models with infinite chi^2 are rejected