implemented longest-common-substring, ported from Common Lisp