added countNeighbors method