Added fix for Adefect with a -1 as the nearest neighbor