anchor.diff:  			 [refac_syntax:atom(undefined)]
   		 end
       end;
  -process_fun_body(AnnAST, ModName,[E |Exprs], Vars) ->
  -    E1 = process_fun_applications(AnnAST, ModName, E, Vars),
  +process_fun_body(Files,AnnAST, ModName,FunName, Arity, [E |Exprs], Vars) ->
  +    E1 = process_fun_applications(Files,AnnAST, ModName,FunName, Arity, E, Vars),
       FreeVars = refac_util:get_free_vars(E1),
       ExportedVars = refac_util:get_var_exports(E1),
       case (ExportedVars -- Vars =/= ExportedVars) of 
  -	true -> [E | process_fun_body(AnnAST, ModName,Exprs, lists:usort(Vars++ExportedVars))];
  +	true -> [E | process_fun_body(Files,AnnAST, ModName, FunName, Arity, Exprs, lists:usort(Vars++ExportedVars))];
   	false -> case FreeVars -- Vars =/= FreeVars of 
   		     true ->
  -			 [E1 | process_fun_body(AnnAST, ModName, Exprs, lists:sort(Vars++refac_util:get_var_exports(E1)))];
  +			 [E1 | process_fun_body(Files,AnnAST, ModName, FunName, Arity, Exprs, lists:sort(Vars++refac_util:get_var_exports(E1)))];
   		     _ ->
  -			 process_fun_body(AnnAST, ModName, Exprs, Vars)
  +			 process_fun_body(Files,AnnAST, ModName, FunName, Arity,Exprs, Vars)
   		 end
       end.
   
   
  -process_fun_applications(AnnAST, ModName, E, Vars) ->
  -    refac_util:full_buTP(fun do_process_fun_applications/2, E, {AnnAST, ModName, Vars}).
  -
  -do_process_fun_applications(Node, {AnnAST, ModName, Vars}) ->
  -    case refac_syntax:type(Node) of 
  +process_fun_applications(Files,AnnAST, ModName, FunName, Arity, E, Vars) ->
  +    refac_util:full_buTP(fun do_process_fun_applications/2, E, {Files,AnnAST, ModName, FunName, Arity, Vars}).
  +
  +do_process_fun_applications(Node, {Files,AnnAST, ModName, FunName, Arity,Vars}) ->
  +      case refac_syntax:type(Node) of 
   	application ->
   	    FreeVars = refac_util:get_free_vars(Node),
   	    case FreeVars -- Vars =/= FreeVars of   %% the function application makes use of some of the variables in Vars;
   		true -> Operator = refac_syntax:application_operator(Node),
   			Ann = refac_syntax:get_ann(Operator),
  +			Args = refac_syntax:application_arguments(Node),
  +			IndexedArgs = lists:zip(lists:seq(1, length(Args)), Args),
  +			FilteredIndexedArgs = lists:filter(fun({_, Arg}) ->
  +								  FVars = refac_util:get_free_vars(Arg),
  +								  FVars -- Vars =/= FVars
  +							  end, IndexedArgs), 
  +			FilteredIndex=element(1, lists:unzip(FilteredIndexedArgs)),
   			case lists:keysearch(fun_def, 1, Ann) of 
  -			    {value, {fun_def, {ModName, F, A, _, DefPos}}} ->   %% TO CHANGE. temperoary only check functions defined in this module;
  -				sliced_funs ! {self(), get, {ModName, F, A}},
  -				receive 
  -				    {value, {{ModName, F, A}, FunDef1}} ->
  -					case returns_undefined(FunDef1) of 
  -					    true ->refac_syntax:atom(undefined);
  -					    _ ->Node
  +			    {value, {fun_def, {M, F, A, _, DefPos}}} ->  
  +				case {M,F,A} of 
  +				    {ModName, FunName, Arity} -> Node;
  +				    _ ->
  +					sliced_funs ! {self(), get, {M, F, A, FilteredIndex}},
  +					receive 
  +					    {sliced_funs, value, {{M, F, A, FilteredIndex}, FunDef1}} ->
  +						case returns_undefined(FunDef1) of 
  +						    true ->refac_syntax:atom(undefined);
  +						    _ ->Node
  +						end;
  +					    _ -> 
  +						FileName1 =lists:filter(fun(F1) -> list_to_atom(filename:basename(F1, ".erl"))==M end, Files),
  +						case FileName1 of 
  +						    [] ->
  +							Node;
  +						    _ -> FileName = hd(FileName1),
  +							 {ok, {AnnAST1, _Info}} = refac_util:parse_annotate_file(FileName, true, Files),
  +							 case refac_util:pos_to_fun_def(AnnAST1, DefPos) of    %% TO check: how to you have this DefPos.
  +							     {ok, FunDef} -> 
  +								 FunDef1= intra_fun_forward_slice(Files,AnnAST, ModName, FunDef, FilteredIndex),
  +								 sliced_funs ! {add, {{M, F, A, FilteredIndex}, FunDef1}},
  +								 case returns_undefined(FunDef1) of 
  +								     true -> refac_syntax:atom(undefined);
  +								     _ -> Node
  +								 end;
  +							     _ -> Node
  +							 end
  +						end
  +					end
   					end;
  -				    _ -> case refac_util:pos_to_fun_def(AnnAST, DefPos) of 
  -					     {ok, FunDef} -> FunDef1= intra_fun_forward_slice(AnnAST, ModName, FunDef, 1), %% TOCHANGE: use 1 temporally;
  -							     sliced_funs ! {add, {{ModName, F, A}, FunDef1}},
  -							     case returns_undefined(FunDef1) of 
  -								 true -> refac_syntax:atom(undefined);
  -								 _ -> Node
  -							     end;
  -					     _ -> Node
  -					 end
  -				end;
  -			    _ -> Node
  -			end;			    
  -		_  -> refac_syntax:atom(undefined)
  -	    end;
  -	_ -> Node
  -    end.
  +				    _ -> Node   %% no fun_def annotation. This should not happen.
  +				end;			    
  +			    _  -> refac_syntax:atom(undefined)
  +			end;
  +		_ -> Node
  +	    end.
   
   %%=========================================================================================================
   %% @spec backward_slice(Files:[filename()], AnnAST:syntaxTree(), ModName::atom(), FunDef::syntaxTree() Expr::syntaxTree()) -> term(). %% Need to think what term() really is.
  
positive.code: -export([forward_slice/5, backward_slice/5]). 
  
  -include("../hrl/wrangler.hrl").
  
  %% @spec forward_slice(Files:[filename()], AnnAST:syntaxTree(), ModName::atom(), FunDef::syntaxTree(), Expr::syntaxTree()) -> [syntaxTree()].
  %% @doc Forward slice the program with expression Expr, which in contained in function FunDef, as the slicing criterion.                     
  
negative.code: 	end.
  
  
  process_a_clause(Files, AnnAST, ModName, FunName, Arity, C, Expr) ->
      ExportedVars = refac_util:get_var_exports(Expr),
      Patterns = refac_syntax:clause_patterns(C),
      Guard = refac_syntax:clause_guard(C),
      Body = refac_syntax:clause_body(C),
      Body1 = rm_unrelated_exprs(Files, AnnAST, ModName, FunName, Arity,  Body, Expr, ExportedVars),
      refac_syntax:clause(Patterns, Guard, Body1).
  
  
  rm_unrelated_exprs(_Files,_AnnAST, _ModName, _FunName, _Arity, [], _Expr, _Vars) ->
      [];
  rm_unrelated_exprs(_Files,_AnnAST, _ModName, _FunName, _Arity,[E], Expr, Vars) ->
      FreeVars = refac_util:get_free_vars(E),
      ExportedVars = refac_util:get_var_exports(E),
      case (ExportedVars -- Vars =/= ExportedVars) of 
  	true -> [E];
  	false -> case FreeVars -- Vars =/= FreeVars of   %% HERE Should check whether the returned value depends on the slice criteron or not!!.
  		     true ->
  			 [E, refac_syntax:atom(undefined)];
  		     _ ->
  			 {Start1, End1} = refac_util:get_range(Expr),
  			 {Start2, End2} =refac_util:get_range(E),
  			 case (Start2 =< Start1) andalso (End1 =< End2) of 
  			     true -> [E, refac_syntax:atom(undefined)];
  			     _ -> [refac_syntax:atom(undefined)]
  			 end
  		 end
      end;
  rm_unrelated_exprs(Files, AnnAST, ModName, FunName, Arity, [E |Exprs], Expr, Vars) ->
      FreeVars = refac_util:get_free_vars(E),
      ExportedVars = refac_util:get_var_exports(E),
      case (ExportedVars -- Vars =/= ExportedVars) of 
  	true -> 
  	    [E | rm_unrelated_exprs(Files,AnnAST, ModName, FunName, Arity, Exprs, Expr, lists:usort(Vars++ExportedVars))];
  	false -> case FreeVars -- Vars =/= FreeVars of 
  		     true ->
  			 Env = refac_util:get_env_vars(E),
  			 E1 = process_fun_applications(Files,AnnAST, ModName, FunName, Arity, E, Vars),
  			 E2 = refac_syntax_lib:annotate_bindings(reset_attrs(E1), Env),
  			 FreeVars1 = refac_util:get_free_vars(E2),
  			 case FreeVars1 --Vars =/= FreeVars1 of 
  			     true ->
  				 [E2 | rm_unrelated_exprs(Files,AnnAST, ModName,  FunName, Arity, Exprs, Expr, lists:sort(Vars++refac_util:get_var_exports(E2)))];
  			     _ ->
  				 {Start1, End1} = refac_util:get_range(Expr),
  				 {Start2, End2} =refac_util:get_range(E2),
  				 case (Start2 =< Start1) andalso (End1 =< End2) of 
  				     true ->  [E2 | rm_unrelated_exprs(Files,AnnAST, ModName,  FunName, Arity, Exprs, Expr, lists:sort(Vars++refac_util:get_var_exports(E2)))];
  				     _ -> rm_unrelated_exprs(Files,AnnAST, ModName, FunName, Arity, Exprs, Expr, Vars)
  				 end
  			 
  			 end;
  		     _ ->
  			 {Start1, End1} = refac_util:get_range(Expr),
  			 {Start2, End2} =refac_util:get_range(E),
  			 case (Start2 =< Start1) andalso (End1 =< End2) of 
  			     true ->  [E | rm_unrelated_exprs(Files,AnnAST, ModName,  FunName, Arity, Exprs, Expr, lists:sort(Vars++refac_util:get_var_exports(E)))];
  			     _ -> rm_unrelated_exprs(Files,AnnAST, ModName, FunName, Arity, Exprs, Expr, Vars)
  			 end
  		 end
      end.
  
  