Add support for nested queries