Doing an refactoring exercise