Better rule handling with nested queries, mongo style