bug fix for 2d, 4-connected case