locking while finding neighbors