Modified lcs function: Not Working Yet