wrong query in delete function