implemented longest common substring