working on query implementation