Updated trend detection logic