Adding counter function to count each tag