Added code for trend analysis