Fixing destroy query bug