figure out the algorithm is too slow and it is not appropriate for the number of cell more than 100