fix really terrible queries