Fix bug introduced by refactoring in LCS algorithm