trend calculation fix