Re-engineering Write Summary Report

merged loops, removed some calculation logic from template