rewrote adding nearby neighbors and increased efficiency