Use helper function to remove duplication
Remove unused variable
Merge pull request #2707 from tricknotes/use-helper-function

Use helper function