Added unioning code for segment creation method