simplify query merging with #reduce