Fix tag logic