better tag logic