better handling of min_occurs and max_occurs