It's much cleaner to use the masking rather than complex vstack, hstack calls.

Apply the masking as suggested, but applied to each scale with the according border size.