better query support + tests