Switch @document from conjunctive conditions to disjunctive conditions.
Implement @document rules (save regexp() conditions). I've still got to select a regexp library to power it.