first refactoring of code