def _process_results(results, keep_N, correlation_threshold=0, thresholds=None):
    """
    Given the results of the CPA, output an array of arrays sorted by most likely candidate first and an array of
    likely incorrect bytes
    """
    possible_keys = []
    likely_wrong = set()

    # plot(results[0])

    for index, r in enumerate(results):
        r = abs(r)
        rMax = r.max(1)

        # did not reach the threshold, it's likely that something went wrong
        # (for example, the key used in a previous step was incorrect)
        threshold = thresholds[index] if thresholds is not None else correlation_threshold
        print("\t\tbyte", index, ": correlation max", rMax.max(), "mean", rMax.mean(), "thresh", threshold)

        if rMax.max() < threshold:
            likely_wrong.add(index)

        possible_keys.append(rMax.argsort()[::-1][:keep_N])

    return possible_keys, likely_wrong