merge lines by percolation