Adding Compact and Flatten