refactored view code for trends