This seems to be quadratic in the amount of rects, no?