trend calc, bug fixed