better handling of relational queries