simplifying the query
Merge pull request #188 from caseysoftware/master

Query tweaks