fix queries with more than two terms