refactor neighbor module(test, but no docstring )