anchor.diff:  	     NewLen = Len-length(Str1) -length(Str21),
   	     case NewLen >= MinLen*2-1 of
   		 true ->
  -		     split_a_clone({NewRanges,{NewLen, F}},lists:reverse(Str22), MinLen);
  +		     split_a_clone({NewRanges,{NewLen, F}},lists:reverse(Str22), MinLen, MinFreq);
   		 _ -> []
   	     end	    
       end.
   
  -split_a_clone(_, "", _)->[];
  -split_a_clone({Ranges, {Len, F}}, Str, MinLen) ->
  +split_a_clone(_, "", _, _)->[];
  +split_a_clone({Ranges, {Len, F}}, Str, MinLen, MinFreq) ->
       {Str1, Str2} = lists:splitwith(fun(C) -> C=/=$# end, Str),
  -    Len1 = length(Str1),
  -    {NewRanges, RemainedRanges} = lists:unzip([{{S, S+Len1-1}, {S+Len1+1, E}}
  +    Len1 = case lists:last(Str1) of 
  +	       $, ->length(Str1)-1;
  +	       _ -> length(Str1)
  +	   end,
  +    {Str21, Str22} = lists:splitwith(fun(C) -> C==$# end, Str2),
  +    {NewRanges, RemainedRanges} = lists:unzip([{{S, S+Len1-1}, {S+length(Str1)+length(Str21), E}}
   					       ||{S, E} <-Ranges]),
  -     case Str2 of 
  -	"" ->
  -	    case Len1>= MinLen*2-1  of
  -		true -> [{NewRanges, {Len1, F}}];
  -		false -> []
  +    case Len1 >= MinLen*2-1 of 
  +	true ->
  +	    NewRanges1 = remove_overlapped_ranges(NewRanges),
  +	    NewFreq = length(NewRanges1),
  +	    case NewFreq>=MinFreq of
  +		true ->
  +		    case Str22 of 
  +			"" ->[{NewRanges1, {Len1, NewFreq}}];
  +			_ ->   [{NewRanges1, {Len1, NewFreq}} | split_a_clone({RemainedRanges, {Len, F}}, Str22, MinLen,MinFreq)]
  +		    end;
  +		false ->
  +		    case Str22 of 
  +			"" ->
  +			    [];
  +			_ -> 
  +			    split_a_clone({RemainedRanges, {Len, F}}, Str22, MinLen,MinFreq)
  +		    end
   	    end;
  -	[$#|Str3] ->
  -	    case Len1>= MinLen*2-1 of
  -		true ->
  -		    [{NewRanges, {Len1, F}} | split_a_clone({RemainedRanges, {Len, F}}, Str3, MinLen)];
  -		false ->
  -		    split_a_clone({RemainedRanges, {Len, F}}, Str3, MinLen)
  -	    end	    
  -    end.
  +	false ->
  +	    case Str22 of 
  +		"" ->
  +		    [];
  +		_ -> 
  +		    split_a_clone({RemainedRanges, {Len, F}}, Str22, MinLen,MinFreq)
  +	    end
  +    end.
  +
      
  -
  +remove_overlapped_ranges(Rs) ->
  +    Rs1 = lists:sort(Rs),
  +    R = hd(Rs1),
  +    remove_overlapped_ranges(tl(Rs1), R, [R]).
  +remove_overlapped_ranges([], _ , Acc) ->
  +    lists:reverse(Acc);
  +remove_overlapped_ranges([{S, E}|Rs], {S1, E1},Acc) ->
  +      case (S1=<S) andalso (S=<E1) of 
  +	true ->
  +	   remove_overlapped_ranges(Rs, {S1, E1}, Acc);
  +	false ->
  +	    remove_overlapped_ranges(Rs, {S, E}, [{S, E}|Acc])
  +    end.
  +	     
  +    
   get_clones_in_ranges(Cs, Data, MinLen, MinFreq, RangeTab) ->
       F0 = fun({S, E}) ->
   		 {_, Ranges}=lists:unzip(lists:sublist(Data, S, E-S+1)),
  
positive.code:     Ranges1=[{{F, SLine, SCol}, {F, EndLine, EndCol}} || 
  		{{F,_, _},{SLine, SCol}, {EndLine, EndCol}} <-Ranges],
      {Ranges1, Len, Freq, C}.
  
  remove_sub_clones(Cs) ->
      remove_sub_clones(lists:reverse(Cs),[]).
  
negative.code: 	_ ->
  	    C={_, {_, Freq}} = lists:last(Cs), 
  	    Res =examine_a_clone_class(C, MinFreq, SimiScore, ASTTab, VarTab, RangeTab),
  	    case Res of
  		[R]  when element(2, R)==Freq ->
  		    Res;
  		_ -> Cs1 = lists:sublist(Cs, 1, length(Cs)-1),
  		     examine_a_clone_set(group_cs(Cs1,[]), MinFreq, SimiScore, ASTTab, VarTab, RangeTab, Pid, Res)
  	    end
      end.
  
  