first part refactoring