public ArrayList<Restaurant> getAllRestaurants() throws IOException {

        Document doc;
        String url;

        ArrayList<Restaurant> rList = new ArrayList<>();

        Set<String> names = new HashSet<>();
        int prevSize = -1;
        for (int i = 1; i <= pages; i++) {

            if (names.size() == prevSize) {
                break;
            }
            prevSize = names.size();

            url = "http://www.fonecta.fi/yritykset/haku/helsinki/Baari/-/" + i + "?sort=ALPHABET";
            doc = null;
            for (int j = 0; j < tries; j++) {
                try {
                    doc = Jsoup.connect(url).get();
                    break;
                } catch (SocketTimeoutException e) {
                    System.err.println("Timed out... Trying again. Tries: " + (j + 1));
                }
            }
            if (doc == null) {
                throw new SocketTimeoutException("Tried " + tries + " times, still no answer... :(");
            }
            
            Elements restaurantDivs = doc.select("li[data-mbs-id]");
            for (Element rDiv : restaurantDivs) {
                Elements nameHrefs = rDiv.select("a[href]");
                if (nameHrefs.size() != 1) {
                    System.err.println("Hmmm... Not one name href...");
                    continue;
                }
                String name = Jsoup.parse(nameHrefs.get(0).html()).text();
                if (names.add(name)) {
                    String address = null;
                    Elements contactDivs = rDiv.select(".address");
                    if (!contactDivs.isEmpty()) {
                        address = Jsoup.parse(contactDivs.get(0).html()).text();
                    }
                    Restaurant restaurant = new Restaurant();
                    restaurant.setName(name);
                    restaurant.setAddress(address);
                    rList.add(restaurant);
                }
            }

            System.out.println("Names after page nr " + i + ": " + names.size());

        }
        Collections.sort(rList);
        return rList;
    }