DRY up some duplication that Code Climate detected

Extracted out two methods to fix some warnings that Code Climate had about duplication.