clean and fix delete function
clean and fix delete function