simplified neighbor-mask creation