Greedy refactoring