second refactoring stage