fixed a bug in delete()