In the next line you are checking if $testId equals $country->id, so why check here if country->id exists?