update Longest Common Prefix