code modified to include counters for measuring number of rounds