Refactoring for kappa calculation and output