Fix a bug for bad neighbors.