renamed flatten to as-flat