added trend_detection formula