Modify longest common subsequence