From Stanfords CS221 class' Conway's Game Of Life tutorial