split query-table into separate functions