Fix bug with returning empty results from query