queries and templates