sample wasn't picking one item at random when misclassified has only one element. Thanks hkReeves for pointing this out