rerewriting for 2d rects