remove trailing spaces before query