refectoring - sami_tag_parse()