created the neighbor count function