refactor get_tag_stats