first version of refactoring