query implementation (wip)