Fixed problem with DB when there is no results in the first query.