handling empty results and failure