Refactoring Logic