Add counters and sorting