simplify the adjacent-patch code