get_query_template function migrated