Fixed a bug in delete functionality