change tag[0] to tag.name