correct the function based on more clear neighbor definition