nested functions in /dataquery to simplify.