updated code for percolation monte carlo simulation