# refactor 'trend' fucntion