refactoring first part