fixed a bug in set_tags
minor improvement to list algorithm