fix errors when query returns no result