Refactoring based on rubocop suggestions