adding some helper functions for fit_maes_trend