refactoring delete method