Refactoring reencoding