Removing Duplication by Refactoring