Implemented toggleCellState method.