anchor.diff:  			{{Year,Month,Day},{Hour,Minute,Second}} = calendar:local_time(),
   			Date = api_help:generate_date([Year,Month,Day]),
   			DateAdded = lib_json:add_values(VirtualStreamJson,[{creation_date, list_to_binary(Date)}]),
  -			case erlastic_search:index_doc(?INDEX, "virtual_stream", DateAdded) of	
  -				{error, Reason} ->
  -					{{error,Reason}, wrq:set_resp_body("{\"error\":\""++ atom_to_list(Reason) ++ "\"}", ReqData), State};
  -				{ok,List} -> 
  -					VirtualStreamId = lib_json:get_field(List, "_id"),
  -					StreamsInvolved = lib_json:get_field(VirtualStreamJson, "streams_involved"),
  -					TimestampFrom = lib_json:get_field(VirtualStreamJson, "timestampfrom"),
  -					Function = lib_json:get_field(VirtualStreamJson, "function"),
  -					AllowedFunctions = ["min", "max", "mean", "total", "diff"],
  -					case lists:member(binary_to_list(lists:nth(1, Function)), AllowedFunctions) of
  -						true ->
  -							Func = binary_to_list(lists:nth(1, Function)),
  -							if 
  -							Func == "diff" andalso length(StreamsInvolved) =/= 1 -> 
  -								{{halt, 404}, wrq:set_resp_body("Wrong number of streams involved for diff", ReqData), State};
  -							true ->	
  -								reduce(VirtualStreamId, StreamsInvolved, TimestampFrom, Function, ReqData, State),
  -								StreamList = [{stream, binary_to_list(X)} || X <- StreamsInvolved],
  -								virtual_stream_process_supervisor:add_child(binary_to_list(VirtualStreamId), StreamList, Function),
  -								
  -								{true, wrq:set_resp_body(lib_json:encode(List), ReqData), State}
  -							end;
  -						false ->
  -							{{halt, 404}, wrq:set_resp_body("404 Function missing or not supported", ReqData), State}
  -					end
  +			StreamsInvolved = lib_json:get_field(VirtualStreamJson, "streams_involved"),
  +			TimestampFrom = lib_json:get_field(VirtualStreamJson, "timestampfrom"),
  +			Function = lib_json:get_field(VirtualStreamJson, "function"),
  +			AllowedFunctions = ["min", "max", "mean", "total", "diff"],
  +			case lists:member(binary_to_list(lists:nth(1, Function)), AllowedFunctions) of
  +				true ->
  +					Func = binary_to_list(lists:nth(1, Function)),
  +					if 
  +						Func == "diff" andalso length(StreamsInvolved) =/= 1 -> 
  +							{{halt, 404}, wrq:set_resp_body("Wrong number of streams involved for diff", ReqData), State};
  +						true ->	
  +							case erlastic_search:index_doc(?INDEX, "virtual_stream", DateAdded) of	
  +								{error, Reason} ->
  +									{{error,Reason}, wrq:set_resp_body("{\"error\":\""++ atom_to_list(Reason) ++ "\"}", ReqData), State};
  +								{ok,List} -> 
  +									VirtualStreamId = lib_json:get_field(List, "_id"),
  +									if 
  +										Func == "diff" ->
  +											ok;
  +										true ->
  +											reduce(VirtualStreamId, StreamsInvolved, TimestampFrom, Function, ReqData, State)
  +									end,
  +									StreamList = [{stream, binary_to_list(X)} || X <- StreamsInvolved],
  +									virtual_stream_process_supervisor:add_child(binary_to_list(VirtualStreamId), StreamList, Function),
  +									{true, wrq:set_resp_body(lib_json:encode(List), ReqData), State}
  +							end
  +					end;
  +				false ->
  +					{{halt, 404}, wrq:set_resp_body("404 Function missing or not supported", ReqData), State}
   			end;
  -				true ->
  -					process_search(ReqData, State, post)
  +		true ->
  +			process_search(ReqData, State, post)
   	end.
   
   
  
positive.code: %% @end
  -spec id_from_path(string()) -> string().
  id_from_path(RD) ->
      case wrq:path_info(id, RD) of
          undefined ->
              case string:tokens(wrq:disp_path(RD), "/") of
                  ["vstreams", Id] -> Id;
                  _ -> undefined
              end;
          Id -> Id
      end.
  
  
  %% @doc
  
negative.code: %% @end
  msToDate(Milliseconds) ->
  	BaseDate = calendar:datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}}),
  	Seconds = BaseDate + (Milliseconds div 1000),
  	Date = calendar:gregorian_seconds_to_datetime(Seconds),
  	{{Year,Month,Day},{Hour,Minute,Second}} = Date,
  	TimeStamp = api_help:generate_timestamp([Year,Month,Day,Hour,Minute,Second],0),
  	TimeStamp.
  