trend updating code