fix tag and ident logic