modified to use performance counters