Replace identical segments