refactoring and example