a piece of code refactoring