Bug fix in delete func