Use template for PR title
Moved complicated codes to a function