update longest-common-prefix