refactored partially satisfy rubocop