only define to_query if it's not already available