Got chisquare function to work