refactoring and style changes a la rubocop