refactoring the delete tool