properly handle queries with no results