finish longest common prefix