magic refactor