That's a lot of code duplication. I think this function should call `num_pattern`, or they both should call another function.