Added logic to check if the JSON array is empty, return to the error function