Outer main loop added for generating activity summary.