separated queries, working multithread implementation