tidied up chisq alleles code