refactoring and progress on neighborhood matching