Refactoring functions about erase.