refactoring code example