refactoring magic