Implemented the delete function.