Implement delete function and fixed edit function