Refactored count_neighbors!