implemented part of query system