improved minhash function gereration