Fixed potential bug in neighborsearching.

Change-Id: I8ef196adc4c9e55e7a51ac829e7308b2a5bfb2ef