fix query terms lookup