updated for wrapping local neighborhood (corrected)