Create floor by room

tell me please, what should I do to make this script do not 8 overlaps, but one big and cut out small ones from it.
on the last picture as it should be in the end.