improved handling of queries with spaces