anchor.diff:  safe_tail(Rem, [_ | Xs]) -> safe_tail(Rem - 1, Xs).
   
   
  +safe_last([]) -> [];
  +safe_last([X]) -> X;
  +safe_last([_ | Xs]) -> safe_last(Xs).
  +
  +
   safe_avg(_Sum, Len) when Len =< 0 -> 0;
   safe_avg(Sum, Len) -> Sum / Len.
   
  
positive.code:                       % fetch additional past data
                        [S] = fetch_data([S0#series.target], From-(WindowPoints * Step), Until, Now),
                        Values = moving_average(S#series.values, WindowPoints),
                        WithTimestamps = with_timestamps(Values, S0#series.start, S#series.step),
                        S#series{values=WithTimestamps, start=S0#series.start, until=S0#series.until}
                end, Series);
  
  % multiplySeries
  
negative.code:     FirstSum = safe_sum(FirstPart),
      FirstAvg = safe_avg(FirstSum, FirstLen),
      Rest = safe_tail(Window, Values),
      FirstValue = get_value(safe_last(FirstPart), FirstAvg),
      lists:reverse(moving_average(Rest, Values, FirstSum, FirstLen, [FirstValue])).
  
  
  moving_average([], _Last, _Sum, _Len, Acc) -> Acc;
  