Add trend function to aid plotting