added error handling: num_per_row/num_per_col too large can lead to out of bounds error when determining replacement clusters in membership assignment