Refactor to fix Rubocop offenses