fix cleanup query