Fixed a bug in cellular automata logic