refactoring stage 1/2