A computer-implemented method of determining a best match for an input, comprising: providing a Ternary Content Addressable Memory, TCAM, table, storing a plurality of TCAM entries, wherein each TCAM entry has an associated output result and each TCAM entry is assigned a precedence value; providing an exact match table, wherein the exact match table stores a plurality of exact match keys, wherein each exact match key has an associated output result and the exact match table is assigned a precedence value; receiving the input; generating a TCAM lookup key from the input; performing a TCAM lookup using the TCAM lookup key to determine a best match TCAM entry; comparing the precedence value of the best match TCAM entry to the precedence value of the exact match table; in response to determining that the precedence value of the exact match table is less than the precedence value of the best match TCAM entry, performing an exact match lookup process, including: generating an exact match lookup key from the input; and using the exact match lookup key to determine if a matching exact match key is contained in the exact match table; and if no matching exact match key is identified, returning the output result associated with the best match TCAM entry as the best match; and if a matching exact match key is identified, returning the output result associated with the matching exact match key as the best match; and wherein the precedence value assigned to each TCAM entry is defined relative to the precedence value assigned to the, or each, exact match table. providing a Ternary Content Addressable Memory, TCAM, table, storing a plurality of TCAM entries, wherein each TCAM entry has an associated output result and each TCAM entry is assigned a precedence value; providing an exact match table, wherein the exact match table stores a plurality of exact match keys, wherein each exact match key has an associated output result and the exact match table is assigned a precedence value; receiving the input; generating a TCAM lookup key from the input; performing a TCAM lookup using the TCAM lookup key to determine a best match TCAM entry; comparing the precedence value of the best match TCAM entry to the precedence value of the exact match table; in response to determining that the precedence value of the exact match table is less than the precedence value of the best match TCAM entry, performing an exact match lookup process, including: generating an exact match lookup key from the input; and using the exact match lookup key to determine if a matching exact match key is contained in the exact match table; and generating an exact match lookup key from the input; and using the exact match lookup key to determine if a matching exact match key is contained in the exact match table; and if no matching exact match key is identified, returning the output result associated with the best match TCAM entry as the best match; and if a matching exact match key is identified, returning the output result associated with the matching exact match key as the best match; and wherein the precedence value assigned to each TCAM entry is defined relative to the precedence value assigned to the, or each, exact match table.