Refactoring and making RuboCop happy