Refactor code duplication.
Minor refactor.