updated code to pick up long term patterns