fixed & improved generatesummary