refactoring intermediate