converted count neighbors to iteration loop, added e5 shim to support forEach method in legacy browsers