global refactoring: stage 3