Handling pairs of shapes that belong together