Fix longest common subsequence issue