private void Step() { List <int> remove = new List <int>(); HashSet <int> check = new HashSet <int>(); List <int> add = new List <int>(); foreach (KeyValuePair <int, Dot> dot in dots) { dot.Value.Update(dots, ref check); if (dot.Value.Dead) { remove.Add(dot.Key); } } foreach (int position in check) { if (Dot.CheckNeighbours(dots, position)) { add.Add(position); } } foreach (int key in remove) { dots.Remove(key); } foreach (int key in add) { dots.Add(key, new Dot(pixelTexture, key)); } }