Changed the way to compute confusion matrix