the percolation algorithm