Fix query composition bug