fixed bug when repeatedly calculating contingency table