anchor.diff:  		   refac_syntax:try_expr_body(Node)
   	   end,
       Fun = fun (ExprStatement) ->
  -		  {Start, End} = refac_util:get_start_end_loc(ExprStatement),
  -		  case Start =< ExprPos andalso ExprPos =< End of
  -		      true ->
  -			  {ExprStatement1, _} = replace_expr_with_var(Expr, NewVarName,
  -								      ExprStatement),
  -                          [refac_util:rewrite(ExprStatement1, MatchExpr), ExprStatement1];
  -		      false ->
  -			  [ExprStatement]
  -		  end
  -	  end,
  -    NewBody = [E1 || E <- Body, E1 <- Fun(E)],
  +                  Range = refac_util:get_start_end_loc_with_comment(ExprStatement),
  +                  NewExpr=refac_syntax:copy_pos(ExprStatement, refac_util:update_ann(MatchExpr, {range, Range})),
  +                  {ExprStatement1, _} = replace_expr_with_var(Expr, NewVarName, ExprStatement),
  +                  [NewExpr, ExprStatement1]
  +          end,
  +    {Body1, Body2} = lists:splitwith(
  +                       fun(E) ->
  +                               {Start, End} = refac_util:get_start_end_loc(E),
  +                               not (Start=<ExprPos andalso ExprPos=<End)
  +                       end, Body),
  +    NewBody =case Body2 of 
  +                 [] ->  
  +                     Body1; 
  +                 [B|Bs] ->
  +                     [B1,B2] = Fun(B),
  +                     case refac_syntax:type(B2)==variable andalso Bs/=[] of
  +                         true ->
  +                             Body1++[B1|Bs];
  +                         false ->
  +                             case {lists:reverse(Body1), Bs} of
  +                                 {[], []} ->
  +                                     [B1,refac_syntax:add_ann({layout, vertical}, B2)];
  +                                 {[], [B3|Bs1]} ->
  +                                     {{BL, _}, _} = refac_util:get_start_end_loc(B),
  +                                     {{B3L, _},_} = refac_util:get_start_end_loc(B3),
  +                                     case BL==B3L of 
  +                                         true ->
  +                                             B21=refac_syntax:add_ann({layout, horizontal}, B2),
  +                                             B31=refac_syntax:add_ann({layout, horizontal}, B3),
  +                                             [B1, B21, B31|Bs1];
  +                                         false ->
  +                                             B21=refac_syntax:add_ann({layout, vertical}, B2),
  +                                             B31=refac_syntax:add_ann({layout, vertical}, B3),
  +                                             [B1, B21, B31|Bs1]
  +                                     end;
  +                                 {[B0|_], []} ->
  +                                     {{B0L, _},_} =refac_util:get_start_end_loc(B0),
  +                                     {{BL, _}, _} = refac_util:get_start_end_loc(B),
  +                                     case B0L==BL of 
  +                                         true ->
  +                                     B21=refac_syntax:add_ann({layout, horizontal}, B2),
  +                                             Body1++[B1,B21];
  +                                         false->
  +                                             B21=refac_syntax:add_ann({layout, vertical}, B2),
  +                                             Body1++[B1, B21]
  +                                     end;
  +                                 {[B0|_], [B3|Bs1]} ->
  +                                     {{B0L, _},_} =refac_util:get_start_end_loc(B0),
  +                                     {{BL, _}, _} = refac_util:get_start_end_loc(B),
  +                                     B21= case B0L==BL of 
  +                                              true ->
  +                                          refac_syntax:add_ann({layout, horizontal}, B2);
  +                                              false->
  +                                                  refac_syntax:add_ann({layout, vertical}, B2)
  +                                          end,
  +                                     case Bs of
  +                                         [] ->
  +                                             Body1++[B1, B21];
  +                                         [B3|Bs1] ->
  +                                             {{B3L, _},_} = refac_util:get_start_end_loc(B3),
  +                                             case BL==B3L of 
  +                                                 true ->
  +                                                     B31=refac_syntax:add_ann({layout, horizontal}, B3),
  +                                                     Body1++[B1, B21, B31|Bs1];
  +                                                 false ->
  +                                                     B31=refac_syntax:add_ann({layout, vertical}, B3),
  +                                                     Body1++[B1, B21, B31|Bs1]
  +                                             end
  +                                     end
  +                             end
  +                     end
  +             end,
       case refac_syntax:type(Node) of
   	clause ->
   	    Pat = refac_syntax:clause_patterns(Node),
  
positive.code: 
  make_match_expr(Expr, NewVarName) ->
      Pat = refac_syntax:variable(NewVarName),
      refac_syntax:match_expr(Pat, Expr).
  
  get_inmost_enclosing_clause(Form, Expr) ->
      ExprPos = refac_syntax:get_pos(Expr),
      Fun = fun (Node, S) ->
  		  Type = refac_syntax:type(Node),
  
negative.code:     end.
  
  cond_check(Form, Expr, NewVarName) ->
      ok=variable_replaceable(Expr),
      {Body, Statement} = get_inmost_enclosing_body_expr(Form, Expr),
      ExprFVs = refac_util:get_free_vars(Expr),
      SEnvs = refac_util:get_env_vars(Statement),
      Vs = [V||{V, Loc}<-ExprFVs--SEnvs, Loc/={0,0}],
      case Vs of
          [] ->
  	    ok;
  	_ ->
  	    Msg = io_lib:format("The exprssion selected contains locally "
  				"declared variables(s) ~p.", [Vs]),
  	    throw({error, lists:flatten(Msg)})
  