1. combine and reduce logic for csv and html