Refactoring and logic