code refactoring, stage 3