fix some problems for neighboring selection.