added qery function, not tested