diff --git a/cluster_consensus.py b/cluster_consensus.py
index e614c1598bb2709fe95f2a746d0a4a803675d8e7..047a5f3fdc2502c97b9c9851ae80c6fd5a076af5 100755
--- a/cluster_consensus.py
+++ b/cluster_consensus.py
@@ -5,6 +5,7 @@ import sys
 import networkx as nx
 import time
 import argparse
+import random
 
 
 # used to get the consensus fragments from a directory of fragments clusters
@@ -124,7 +125,6 @@ def fragConsensus(frag_list, frag_length):
         if len(cluster) != 0:
             clusters_list.append(cluster)
         kmers_positions[kmer] = clusters_list
-    
     # construct a list of pkmers
     # a pkmer is an object containing a kmer & his average_position & weight
     # example: ACCTGAGT:23:10
@@ -222,13 +222,15 @@ def consensusOnFragDir(frag_dir_path, output_path, frag_length, n_reads):
         cluster_file.close()
         
         if n_reads is not None:
-            frag_list = frag_list[:n_reads]
+            frag_list = random.sample(frag_list, min(len(frag_list), n_reads))
         
         consensus_sequence = fragConsensus(frag_list, frag_length)
         #if len(consensus_sequence) >= 2*frag_length/3:
-            
+
         consensus_file.write(">consensus_of_"+cluster_filename+"\n")
         consensus_file.write(consensus_sequence+"\n")
+        #if len(consensus_sequence) < 2*frag_length/3:
+            #print(cluster_filename)
 
         computed_consensus += 1
     consensus_file.close()