added code to address reveiwer comment about detecting trends