combine_pattern function