Refactoring based on rubocop feedback