faster implemenation using 2 suffix arrays and looking for the contents of one (reversed) in the other by order of longest to shortest. still too slow.