global refactoring: stage 1