Bug refactoring