optimise rule lookup with prefixes
optimise rule lookup with prefixes