Added chisquare function