added the code for lcs