query impl - work in progress