added try catch when checking for number of results