Add handling of queries