Minor refactoring for erasing repeated code.