the queries and functions