added updateState function to update the state of a cell