Added trimming to queries