fixed error to visit cells multiple times