anchor.diff:  					 refac_syntax:tuple_elements(LastExp));
   		      _  -> false
   		  end,
  +    
         Fun = fun(T, S) ->
   		  case refac_syntax:type(T) of 
   		      clause ->
   			  Exprs = refac_syntax:clause_body(T),
   			  SubExprs = sublists(Exprs, Len),
   		          CandidateExprs1 = 
  -			      lists:map(fun(E) -> case ExpList =/= E of 
  -						      true ->case expr_unification(ExpList, E) of 
  -								 {true,Subst} -> {StartLoc1, _EndLoc1} = refac_util:get_range(hd(E)),
  -										 {_StartLoc2, EndLoc2} = refac_util:get_range(lists:last(E)),
  -										 {{StartLoc1, EndLoc2}, Subst};
  -								 _ -> false
  -							     end;
  -						      _ -> false
  -						  end							       
  -					end, SubExprs),
  -			  CandidateExprs2 = 
  +			         lists:map(fun(E) -> case ExpList =/= E of 
  +   						      true ->case expr_unification(ExpList, E) of 
  +   								 {true,Subst} -> {StartLoc1, _EndLoc1} = refac_util:get_range(hd(E)),
  +   										 {_StartLoc2, EndLoc2} = refac_util:get_range(lists:last(E)),
  +   										 {{StartLoc1, EndLoc2}, Subst};
  +   								 _ -> false
  +   							     end;
  +   						      _ -> false
  +   						  end							       
  +   					end, SubExprs),
  + 			  CandidateExprs2 = 
   			      case HasExportExp of 
   				  true ->
   				      SubExprs1 = sublists(Exprs, Len-1),
   				      lists:map(fun(E) -> case hd(ExpList) =/= hd(E) of 
  -							      true -> VarsToExport = vars_to_export(Exprs, E),
  -								      E1 = case VarsToExport of 
  -									       [] -> E;
  -									       [V] ->  E ++ [refac_syntax:variable(V)];
  -									       [_V|_VS] -> E++[refac_syntax:tuple([refac_syntax:variable(V) || V <-VarsToExport])]
  -									   end,
  -								      case expr_unification(ExpList, E1) of 
  +							      true -> VarsToExport = vars_to_export_1(Exprs, E),
  +								      Res =  expr_unification(lists:sublist(ExpList, Len-1), E),
  +								      case Res of 
   									  {true, Subst} ->
  -									      {StartLoc1, _EndLoc1} = refac_util:get_range(hd(E)),
  -									      {_StartLoc2, EndLoc2} = refac_util:get_range(lists:last(E)),
  -									      {{StartLoc1, EndLoc2}, Subst, VarsToExport};
  +									      case reorder_vars_to_export(LastExp, VarsToExport, Subst) of 
  +										  {true, VarsToExport1} ->
  +										      {StartLoc1, _EndLoc1} = refac_util:get_range(hd(E)),
  +										      {_StartLoc2, EndLoc2} = refac_util:get_range(lists:last(E)),
  +										      {{StartLoc1, EndLoc2}, Subst, VarsToExport1};
  +										  _ -> false
  +									      end;
   									  _ -> false
   								      end;
   							      _ -> false
  
positive.code:     VarsToExport.
  
  
      
  get_fun_clause_def(Node, FunName, Arity, ClauseIndex) ->
      case refac_util:once_tdTU(fun get_fun_def_1/2, Node, {FunName, Arity, ClauseIndex}) of
  
negative.code:     
  
  expr_unification(Exp1, Exp2) ->
      Res1 = case {is_list(Exp1), is_list(Exp2)} of 
  	{true, true} ->   %% both are list of expressions
  	    case length(Exp1) == length(Exp2) of
  		true -> Res = lists:map(fun({E1,E2}) ->			      
  