global refactoring: stage 2