I optimize repetitive code

Comment From: sbrannen

This has been merged into main in 324c6057fd5c354bdfab83c5aa26a5e83ba5d64a and revised in 0093d6e34d8dc99f6881c4f5be983721cec4dacb.

Thanks

Comment From: luohongtu

I need a contributor.

Comment From: sbrannen

Hi @luohongtu,

Your PR has already been merged, so what do you mean by the following?

I need a contributor.