Compacting parts if consecutive strings